Skip to content

Commit 3f02813

Browse files
authored
Merge branch 'master' into lfs-data-mirroring
2 parents e7941de + ec06eb1 commit 3f02813

File tree

158 files changed

+3677
-1403
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

158 files changed

+3677
-1403
lines changed

go.mod

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ require (
4646
github.com/google/go-github/v32 v32.1.0
4747
github.com/google/uuid v1.2.0
4848
github.com/gorilla/context v1.1.1
49+
github.com/gorilla/sessions v1.2.1 // indirect
50+
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
4951
github.com/hashicorp/go-retryablehttp v0.6.8 // indirect
5052
github.com/hashicorp/go-version v1.2.1
5153
github.com/huandu/xstrings v1.3.2
@@ -57,7 +59,7 @@ require (
5759
github.com/keybase/go-crypto v0.0.0-20200123153347-de78d2cb44f4
5860
github.com/klauspost/compress v1.11.7
5961
github.com/klauspost/pgzip v1.2.5 // indirect
60-
github.com/lafriks/xormstore v1.3.2
62+
github.com/lafriks/xormstore v1.4.0
6163
github.com/lib/pq v1.9.0
6264
github.com/lunny/dingtalk_webhook v0.0.0-20171025031554-e3534c89ef96
6365
github.com/markbates/goth v1.66.1
@@ -69,7 +71,7 @@ require (
6971
github.com/mholt/archiver/v3 v3.5.0
7072
github.com/microcosm-cc/bluemonday v1.0.4
7173
github.com/minio/md5-simd v1.1.1 // indirect
72-
github.com/minio/minio-go/v7 v7.0.7
74+
github.com/minio/minio-go/v7 v7.0.9
7375
github.com/mitchellh/go-homedir v1.1.0
7476
github.com/msteinert/pam v0.0.0-20200810204841-913b8f8cdf8b
7577
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
@@ -80,7 +82,7 @@ require (
8082
github.com/pierrec/lz4/v4 v4.1.1 // indirect
8183
github.com/pkg/errors v0.9.1
8284
github.com/pquerna/otp v1.3.0
83-
github.com/prometheus/client_golang v1.8.0
85+
github.com/prometheus/client_golang v1.9.0
8486
github.com/quasoft/websspi v1.0.0
8587
github.com/rivo/uniseg v0.2.0 // indirect
8688
github.com/sergi/go-diff v1.1.0
@@ -98,16 +100,16 @@ require (
98100
github.com/unrolled/render v1.0.3
99101
github.com/urfave/cli v1.22.5
100102
github.com/willf/bitset v1.1.11 // indirect
101-
github.com/xanzy/go-gitlab v0.42.0
103+
github.com/xanzy/go-gitlab v0.44.0
102104
github.com/yohcop/openid-go v1.0.0
103-
github.com/yuin/goldmark v1.3.1
105+
github.com/yuin/goldmark v1.3.2
104106
github.com/yuin/goldmark-highlighting v0.0.0-20200307114337-60d527fdb691
105107
github.com/yuin/goldmark-meta v1.0.0
106108
go.jolheiser.com/hcaptcha v0.0.4
107109
go.jolheiser.com/pwn v0.0.3
108110
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad
109111
golang.org/x/net v0.0.0-20210119194325-5f4716e94777
110-
golang.org/x/oauth2 v0.0.0-20210126194326-f9ce19ea3013
112+
golang.org/x/oauth2 v0.0.0-20210210192628-66670185b0cd
111113
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c
112114
golang.org/x/text v0.3.5
113115
golang.org/x/time v0.0.0-20201208040808-7e3f01d25324 // indirect
@@ -118,8 +120,8 @@ require (
118120
gopkg.in/yaml.v2 v2.4.0
119121
mvdan.cc/xurls/v2 v2.2.0
120122
strk.kbt.io/projects/go/libravatar v0.0.0-20191008002943-06d1c002b251
121-
xorm.io/builder v0.3.7
122-
xorm.io/xorm v1.0.6
123+
xorm.io/builder v0.3.9
124+
xorm.io/xorm v1.0.7
123125
)
124126

125127
replace github.com/hashicorp/go-version => github.com/6543/go-version v1.2.4

go.sum

Lines changed: 23 additions & 37 deletions
Large diffs are not rendered by default.

models/user.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,17 @@ const (
5656
algoScrypt = "scrypt"
5757
algoArgon2 = "argon2"
5858
algoPbkdf2 = "pbkdf2"
59+
)
60+
61+
// AvailableHashAlgorithms represents the available password hashing algorithms
62+
var AvailableHashAlgorithms = []string{
63+
algoPbkdf2,
64+
algoArgon2,
65+
algoScrypt,
66+
algoBcrypt,
67+
}
5968

69+
const (
6070
// EmailNotificationsEnabled indicates that the user would like to receive all email notifications
6171
EmailNotificationsEnabled = "enabled"
6272
// EmailNotificationsOnMention indicates that the user would like to be notified via email when mentioned.

modules/forms/user_form.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ type InstallForm struct {
6060
DefaultEnableTimetracking bool
6161
NoReplyAddress string
6262

63+
PasswordAlgorithm string
64+
6365
AdminName string `binding:"OmitEmpty;AlphaDashDot;MaxSize(30)" locale:"install.admin_name"`
6466
AdminPasswd string `binding:"OmitEmpty;MaxSize(255)" locale:"install.admin_password"`
6567
AdminConfirmPasswd string

modules/git/parse_gogit.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,21 @@ import (
1010
"bytes"
1111
"fmt"
1212
"strconv"
13+
"strings"
1314

1415
"github.com/go-git/go-git/v5/plumbing/filemode"
1516
"github.com/go-git/go-git/v5/plumbing/object"
1617
)
1718

18-
// ParseTreeEntries parses the output of a `git ls-tree` command.
19+
// ParseTreeEntries parses the output of a `git ls-tree -l` command.
1920
func ParseTreeEntries(data []byte) ([]*TreeEntry, error) {
2021
return parseTreeEntries(data, nil)
2122
}
2223

2324
func parseTreeEntries(data []byte, ptree *Tree) ([]*TreeEntry, error) {
2425
entries := make([]*TreeEntry, 0, 10)
2526
for pos := 0; pos < len(data); {
26-
// expect line to be of the form "<mode> <type> <sha>\t<filename>"
27+
// expect line to be of the form "<mode> <type> <sha> <space-padded-size>\t<filename>"
2728
entry := new(TreeEntry)
2829
entry.gogitTreeEntry = &object.TreeEntry{}
2930
entry.ptree = ptree
@@ -61,7 +62,16 @@ func parseTreeEntries(data []byte, ptree *Tree) ([]*TreeEntry, error) {
6162
entry.gogitTreeEntry.Hash = id
6263
pos += 41 // skip over sha and trailing space
6364

64-
end := pos + bytes.IndexByte(data[pos:], '\n')
65+
end := pos + bytes.IndexByte(data[pos:], '\t')
66+
if end < pos {
67+
return nil, fmt.Errorf("Invalid ls-tree -l output: %s", string(data))
68+
}
69+
entry.size, _ = strconv.ParseInt(strings.TrimSpace(string(data[pos:end])), 10, 64)
70+
entry.sized = true
71+
72+
pos = end + 1
73+
74+
end = pos + bytes.IndexByte(data[pos:], '\n')
6575
if end < pos {
6676
return nil, fmt.Errorf("Invalid ls-tree output: %s", string(data))
6777
}

modules/git/parse_gogit_test.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func TestParseTreeEntries(t *testing.T) {
2424
Expected: []*TreeEntry{},
2525
},
2626
{
27-
Input: "100644 blob 61ab7345a1a3bbc590068ccae37b8515cfc5843c\texample/file2.txt\n",
27+
Input: "100644 blob 61ab7345a1a3bbc590068ccae37b8515cfc5843c 1022\texample/file2.txt\n",
2828
Expected: []*TreeEntry{
2929
{
3030
ID: MustIDFromString("61ab7345a1a3bbc590068ccae37b8515cfc5843c"),
@@ -33,12 +33,14 @@ func TestParseTreeEntries(t *testing.T) {
3333
Name: "example/file2.txt",
3434
Mode: filemode.Regular,
3535
},
36+
size: 1022,
37+
sized: true,
3638
},
3739
},
3840
},
3941
{
40-
Input: "120000 blob 61ab7345a1a3bbc590068ccae37b8515cfc5843c\t\"example/\\n.txt\"\n" +
41-
"040000 tree 1d01fb729fb0db5881daaa6030f9f2d3cd3d5ae8\texample\n",
42+
Input: "120000 blob 61ab7345a1a3bbc590068ccae37b8515cfc5843c 234131\t\"example/\\n.txt\"\n" +
43+
"040000 tree 1d01fb729fb0db5881daaa6030f9f2d3cd3d5ae8 -\texample\n",
4244
Expected: []*TreeEntry{
4345
{
4446
ID: MustIDFromString("61ab7345a1a3bbc590068ccae37b8515cfc5843c"),
@@ -47,9 +49,12 @@ func TestParseTreeEntries(t *testing.T) {
4749
Name: "example/\n.txt",
4850
Mode: filemode.Symlink,
4951
},
52+
size: 234131,
53+
sized: true,
5054
},
5155
{
52-
ID: MustIDFromString("1d01fb729fb0db5881daaa6030f9f2d3cd3d5ae8"),
56+
ID: MustIDFromString("1d01fb729fb0db5881daaa6030f9f2d3cd3d5ae8"),
57+
sized: true,
5358
gogitTreeEntry: &object.TreeEntry{
5459
Hash: MustIDFromString("1d01fb729fb0db5881daaa6030f9f2d3cd3d5ae8"),
5560
Name: "example",

modules/git/parse_nogogit.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,18 @@ import (
1010
"bytes"
1111
"fmt"
1212
"strconv"
13+
"strings"
1314
)
1415

15-
// ParseTreeEntries parses the output of a `git ls-tree` command.
16+
// ParseTreeEntries parses the output of a `git ls-tree -l` command.
1617
func ParseTreeEntries(data []byte) ([]*TreeEntry, error) {
1718
return parseTreeEntries(data, nil)
1819
}
1920

2021
func parseTreeEntries(data []byte, ptree *Tree) ([]*TreeEntry, error) {
2122
entries := make([]*TreeEntry, 0, 10)
2223
for pos := 0; pos < len(data); {
23-
// expect line to be of the form "<mode> <type> <sha>\t<filename>"
24+
// expect line to be of the form "<mode> <type> <sha> <space-padded-size>\t<filename>"
2425
entry := new(TreeEntry)
2526
entry.ptree = ptree
2627
if pos+6 > len(data) {
@@ -56,7 +57,16 @@ func parseTreeEntries(data []byte, ptree *Tree) ([]*TreeEntry, error) {
5657
entry.ID = id
5758
pos += 41 // skip over sha and trailing space
5859

59-
end := pos + bytes.IndexByte(data[pos:], '\n')
60+
end := pos + bytes.IndexByte(data[pos:], '\t')
61+
if end < pos {
62+
return nil, fmt.Errorf("Invalid ls-tree -l output: %s", string(data))
63+
}
64+
entry.size, _ = strconv.ParseInt(strings.TrimSpace(string(data[pos:end])), 10, 64)
65+
entry.sized = true
66+
67+
pos = end + 1
68+
69+
end = pos + bytes.IndexByte(data[pos:], '\n')
6070
if end < pos {
6171
return nil, fmt.Errorf("Invalid ls-tree output: %s", string(data))
6272
}

modules/git/parse_nogogit_test.go

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// Copyright 2021 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
// +build !gogit
6+
7+
package git
8+
9+
import (
10+
"testing"
11+
12+
"github.com/stretchr/testify/assert"
13+
)
14+
15+
func TestParseTreeEntries(t *testing.T) {
16+
17+
testCases := []struct {
18+
Input string
19+
Expected []*TreeEntry
20+
}{
21+
{
22+
Input: `100644 blob ea0d83c9081af9500ac9f804101b3fd0a5c293af 8218 README.md
23+
100644 blob 037f27dc9d353ae4fd50f0474b2194c593914e35 4681 README_ZH.md
24+
100644 blob 9846a94f7e8350a916632929d0fda38c90dd2ca8 429 SECURITY.md
25+
040000 tree 84b90550547016f73c5dd3f50dea662389e67b6d - assets
26+
`,
27+
Expected: []*TreeEntry{
28+
{
29+
ID: MustIDFromString("ea0d83c9081af9500ac9f804101b3fd0a5c293af"),
30+
name: "README.md",
31+
entryMode: EntryModeBlob,
32+
size: 8218,
33+
sized: true,
34+
},
35+
{
36+
ID: MustIDFromString("037f27dc9d353ae4fd50f0474b2194c593914e35"),
37+
name: "README_ZH.md",
38+
entryMode: EntryModeBlob,
39+
size: 4681,
40+
sized: true,
41+
},
42+
{
43+
ID: MustIDFromString("9846a94f7e8350a916632929d0fda38c90dd2ca8"),
44+
name: "SECURITY.md",
45+
entryMode: EntryModeBlob,
46+
size: 429,
47+
sized: true,
48+
},
49+
{
50+
ID: MustIDFromString("84b90550547016f73c5dd3f50dea662389e67b6d"),
51+
name: "assets",
52+
entryMode: EntryModeTree,
53+
sized: true,
54+
},
55+
},
56+
},
57+
}
58+
for _, testCase := range testCases {
59+
entries, err := ParseTreeEntries([]byte(testCase.Input))
60+
assert.NoError(t, err)
61+
assert.EqualValues(t, len(testCase.Expected), len(entries))
62+
for i, entry := range entries {
63+
assert.EqualValues(t, testCase.Expected[i].ID, entry.ID)
64+
assert.EqualValues(t, testCase.Expected[i].name, entry.name)
65+
assert.EqualValues(t, testCase.Expected[i].entryMode, entry.entryMode)
66+
assert.EqualValues(t, testCase.Expected[i].sized, entry.sized)
67+
assert.EqualValues(t, testCase.Expected[i].size, entry.size)
68+
}
69+
}
70+
}

modules/git/repo_compare.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ import (
2020

2121
// CompareInfo represents needed information for comparing references.
2222
type CompareInfo struct {
23-
MergeBase string
24-
Commits *list.List
25-
NumFiles int
23+
MergeBase string
24+
BaseCommitID string
25+
HeadCommitID string
26+
Commits *list.List
27+
NumFiles int
2628
}
2729

2830
// GetMergeBase checks and returns merge base of two branches and the reference used as base.
@@ -66,8 +68,18 @@ func (repo *Repository) GetCompareInfo(basePath, baseBranch, headBranch string)
6668
}
6769

6870
compareInfo := new(CompareInfo)
71+
72+
compareInfo.HeadCommitID, err = GetFullCommitID(repo.Path, headBranch)
73+
if err != nil {
74+
compareInfo.HeadCommitID = headBranch
75+
}
76+
6977
compareInfo.MergeBase, remoteBranch, err = repo.GetMergeBase(tmpRemote, baseBranch, headBranch)
7078
if err == nil {
79+
compareInfo.BaseCommitID, err = GetFullCommitID(repo.Path, remoteBranch)
80+
if err != nil {
81+
compareInfo.BaseCommitID = remoteBranch
82+
}
7183
// We have a common base - therefore we know that ... should work
7284
logs, err := NewCommand("log", compareInfo.MergeBase+"..."+headBranch, prettyLogFormat).RunInDirBytes(repo.Path)
7385
if err != nil {
@@ -83,6 +95,7 @@ func (repo *Repository) GetCompareInfo(basePath, baseBranch, headBranch string)
8395
if err != nil {
8496
compareInfo.MergeBase = remoteBranch
8597
}
98+
compareInfo.BaseCommitID = compareInfo.MergeBase
8699
}
87100

88101
// Count number of changed files.

0 commit comments

Comments
 (0)