Skip to content

Commit 663bc8e

Browse files
authored
Merge branch 'master' into enh/noid/commit-message-link-check-commit-hashes
2 parents 026c84a + 52feff5 commit 663bc8e

38 files changed

+551
-88
lines changed

.drone.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ steps:
6666
image: golang:1.11 # this step is kept as the lowest version of golang that we support
6767
environment:
6868
GO111MODULE: on
69+
GOPROXY: off
6970
commands:
7071
- go build -mod=vendor -o gitea_no_gcc # test if build succeeds without the sqlite tag
7172

@@ -74,6 +75,7 @@ steps:
7475
image: golang:1.12
7576
environment:
7677
GO111MODULE: on
78+
GOPROXY: off
7779
GOOS: linux
7880
GOARCH: 386
7981
commands:
@@ -92,6 +94,7 @@ steps:
9294
- make test-vendor
9395
- make build
9496
environment:
97+
GOPROXY: https://goproxy.cn # proxy.golang.org is blocked in China, this proxy is not
9598
TAGS: bindata sqlite sqlite_unlock_notify
9699

97100
- name: unit-test
@@ -100,6 +103,7 @@ steps:
100103
commands:
101104
- make unit-test-coverage
102105
environment:
106+
GOPROXY: off
103107
TAGS: bindata sqlite sqlite_unlock_notify
104108
depends_on:
105109
- build
@@ -116,6 +120,7 @@ steps:
116120
commands:
117121
- make test
118122
environment:
123+
GOPROXY: off
119124
TAGS: bindata sqlite sqlite_unlock_notify
120125
depends_on:
121126
- build
@@ -143,6 +148,7 @@ steps:
143148
commands:
144149
- make test
145150
environment:
151+
GOPROXY: off
146152
TAGS: bindata
147153
depends_on:
148154
- tag-pre-condition
@@ -159,6 +165,7 @@ steps:
159165
- timeout -s ABRT 20m make test-sqlite-migration
160166
- timeout -s ABRT 20m make test-sqlite
161167
environment:
168+
GOPROXY: off
162169
TAGS: bindata
163170
depends_on:
164171
- build
@@ -172,6 +179,7 @@ steps:
172179
- make test-mysql-migration
173180
- make integration-test-coverage
174181
environment:
182+
GOPROXY: off
175183
TAGS: bindata
176184
TEST_LDAP: 1
177185
depends_on:
@@ -192,6 +200,7 @@ steps:
192200
- timeout -s ABRT 20m make test-mysql-migration
193201
- timeout -s ABRT 20m make test-mysql
194202
environment:
203+
GOPROXY: off
195204
TAGS: bindata
196205
TEST_LDAP: 1
197206
depends_on:
@@ -209,6 +218,7 @@ steps:
209218
- timeout -s ABRT 20m make test-mysql8-migration
210219
- timeout -s ABRT 20m make test-mysql8
211220
environment:
221+
GOPROXY: off
212222
TAGS: bindata
213223
TEST_LDAP: 1
214224
depends_on:
@@ -223,6 +233,7 @@ steps:
223233
- timeout -s ABRT 20m make test-pgsql-migration
224234
- timeout -s ABRT 20m make test-pgsql
225235
environment:
236+
GOPROXY: off
226237
TAGS: bindata
227238
TEST_LDAP: 1
228239
depends_on:
@@ -237,6 +248,7 @@ steps:
237248
- make test-mssql-migration
238249
- make test-mssql
239250
environment:
251+
GOPROXY: off
240252
TAGS: bindata
241253
TEST_LDAP: 1
242254
depends_on:
@@ -248,6 +260,7 @@ steps:
248260
commands:
249261
- make coverage
250262
environment:
263+
GOPROXY: off
251264
TAGS: bindata
252265
depends_on:
253266
- unit-test
@@ -380,6 +393,7 @@ steps:
380393
- make generate
381394
- make release
382395
environment:
396+
GOPROXY: off
383397
TAGS: bindata sqlite sqlite_unlock_notify
384398

385399
- name: gpg-sign
@@ -481,6 +495,7 @@ steps:
481495
- make generate
482496
- make release
483497
environment:
498+
GOPROXY: off
484499
TAGS: bindata sqlite sqlite_unlock_notify
485500

486501
- name: gpg-sign
@@ -607,6 +622,8 @@ steps:
607622
dry_run: true
608623
repo: gitea/gitea
609624
tags: linux-amd64
625+
build_args:
626+
- GOPROXY=off
610627
when:
611628
event:
612629
- pull_request
@@ -618,6 +635,8 @@ steps:
618635
auto_tag: true
619636
auto_tag_suffix: linux-amd64
620637
repo: gitea/gitea
638+
build_args:
639+
- GOPROXY=off
621640
password:
622641
from_secret: docker_password
623642
username:
@@ -668,6 +687,8 @@ steps:
668687
dry_run: true
669688
repo: gitea/gitea
670689
tags: linux-arm64
690+
build_args:
691+
- GOPROXY=off
671692
when:
672693
event:
673694
- pull_request
@@ -679,6 +700,8 @@ steps:
679700
auto_tag: true
680701
auto_tag_suffix: linux-arm64
681702
repo: gitea/gitea
703+
build_args:
704+
- GOPROXY=off
682705
password:
683706
from_secret: docker_password
684707
username:

Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
#Build stage
44
FROM golang:1.12-alpine3.10 AS build-env
55

6+
ARG GOPROXY
7+
ENV GOPROXY ${GOPROXY:-direct}
8+
69
ARG GITEA_VERSION
710
ARG TAGS="sqlite sqlite_unlock_notify"
811
ENV TAGS "bindata $TAGS"

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ require (
115115
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
116116
gopkg.in/asn1-ber.v1 v1.0.0-20150924051756-4e86f4367175 // indirect
117117
gopkg.in/bufio.v1 v1.0.0-20140618132640-567b2bfa514e // indirect
118-
gopkg.in/editorconfig/editorconfig-core-go.v1 v1.2.0
118+
gopkg.in/editorconfig/editorconfig-core-go.v1 v1.3.0
119119
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
120120
gopkg.in/ini.v1 v1.42.0
121121
gopkg.in/ldap.v3 v3.0.2

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,8 +451,8 @@ gopkg.in/bufio.v1 v1.0.0-20140618132640-567b2bfa514e/go.mod h1:xsQCaysVCudhrYTfz
451451
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
452452
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
453453
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
454-
gopkg.in/editorconfig/editorconfig-core-go.v1 v1.2.0 h1:CO465/foR4+bY1xNYjZEl6l8By1g/iMsImoruxfEt84=
455-
gopkg.in/editorconfig/editorconfig-core-go.v1 v1.2.0/go.mod h1:s2mQFI9McjArkyCwyEwU//+luQENTnD/Lfb/7Sj3/kQ=
454+
gopkg.in/editorconfig/editorconfig-core-go.v1 v1.3.0 h1:oxOEwvhxLMpWpN+0pb2r9TWrM0DCFBHxbuIlS27tmFg=
455+
gopkg.in/editorconfig/editorconfig-core-go.v1 v1.3.0/go.mod h1:s2mQFI9McjArkyCwyEwU//+luQENTnD/Lfb/7Sj3/kQ=
456456
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
457457
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
458458
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df h1:n7WqCuqOuCbNr617RXOY0AWRXxgwEyPp2z+p0+hgMuE=

models/fixtures/org_user.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,9 @@
3939
uid: 20
4040
org_id: 19
4141
is_public: true
42+
43+
-
44+
id: 8
45+
uid: 24
46+
org_id: 25
47+
is_public: true

models/fixtures/team.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,13 @@
7777
name: review_team
7878
authorize: 1 # read
7979
num_repos: 1
80-
num_members: 1
80+
num_members: 1
81+
82+
-
83+
id: 10
84+
org_id: 25
85+
lower_name: notowners
86+
name: NotOwners
87+
authorize: 1 # owner
88+
num_repos: 0
89+
num_members: 1

models/fixtures/team_user.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,10 @@
6262
id: 11
6363
org_id: 17
6464
team_id: 9
65-
uid: 20
65+
uid: 20
66+
67+
-
68+
id: 12
69+
org_id: 25
70+
team_id: 10
71+
uid: 24

models/fixtures/two_factor.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
-
2+
id: 1
3+
uid: 24
4+
secret: KlDporn6Ile4vFcKI8z7Z6sqK1Scj2Qp0ovtUzCZO6jVbRW2lAoT7UDxDPtrab8d2B9zKOocBRdBJnS8orsrUNrsyETY+jJHb79M82uZRioKbRUz15sfOpmJmEzkFeSg6S4LicUBQos=
5+
scratch_salt: Qb5bq2DyR2
6+
scratch_hash: 068eb9b8746e0bcfe332fac4457693df1bda55800eb0f6894d14ebb736ae6a24e0fc8fc5333c19f57f81599788f0b8e51ec1
7+
last_used_passcode:
8+
created_unix: 1564253724
9+
updated_unix: 1564253724

models/fixtures/user.yml

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,4 +365,39 @@
365365
is_active: true
366366
num_members: 0
367367
num_teams: 0
368-
visibility: 2
368+
visibility: 2
369+
370+
-
371+
id: 24
372+
lower_name: user24
373+
name: user24
374+
full_name: "user24"
375+
376+
keep_email_private: true
377+
passwd: 7d93daa0d1e6f2305cc8fa496847d61dc7320bb16262f9c55dd753480207234cdd96a93194e408341971742f4701772a025a # password
378+
type: 0 # individual
379+
salt: ZogKvWdyEx
380+
is_admin: false
381+
avatar: avatar24
382+
avatar_email: [email protected]
383+
num_repos: 0
384+
num_stars: 0
385+
num_followers: 0
386+
num_following: 0
387+
is_active: true
388+
389+
-
390+
id: 25
391+
lower_name: org25
392+
name: org25
393+
full_name: "org25"
394+
395+
passwd: 7d93daa0d1e6f2305cc8fa496847d61dc7320bb16262f9c55dd753480207234cdd96a93194e408341971742f4701772a025a # password
396+
type: 1 # organization
397+
salt: ZogKvWdyEx
398+
is_admin: false
399+
avatar: avatar25
400+
avatar_email: [email protected]
401+
num_repos: 0
402+
num_members: 1
403+
num_teams: 1

models/migrate.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,38 +62,50 @@ func insertIssue(sess *xorm.Session, issue *Issue) error {
6262
if _, err := sess.Insert(issueLabels); err != nil {
6363
return err
6464
}
65+
66+
cols := make([]string, 0)
6567
if !issue.IsPull {
6668
sess.ID(issue.RepoID).Incr("num_issues")
69+
cols = append(cols, "num_issues")
6770
if issue.IsClosed {
6871
sess.Incr("num_closed_issues")
72+
cols = append(cols, "num_closed_issues")
6973
}
7074
} else {
7175
sess.ID(issue.RepoID).Incr("num_pulls")
76+
cols = append(cols, "num_pulls")
7277
if issue.IsClosed {
7378
sess.Incr("num_closed_pulls")
79+
cols = append(cols, "num_closed_pulls")
7480
}
7581
}
76-
if _, err := sess.NoAutoTime().Update(issue.Repo); err != nil {
82+
if _, err := sess.NoAutoTime().Cols(cols...).Update(issue.Repo); err != nil {
7783
return err
7884
}
7985

86+
cols = []string{"num_issues"}
8087
sess.Incr("num_issues")
8188
if issue.IsClosed {
8289
sess.Incr("num_closed_issues")
90+
cols = append(cols, "num_closed_issues")
8391
}
84-
if _, err := sess.In("id", labelIDs).NoAutoTime().Update(new(Label)); err != nil {
92+
if _, err := sess.In("id", labelIDs).NoAutoTime().Cols(cols...).Update(new(Label)); err != nil {
8593
return err
8694
}
8795

8896
if issue.MilestoneID > 0 {
97+
cols = []string{"num_issues"}
8998
sess.Incr("num_issues")
99+
cl := "num_closed_issues"
90100
if issue.IsClosed {
91101
sess.Incr("num_closed_issues")
102+
cols = append(cols, "num_closed_issues")
103+
cl = "(num_closed_issues + 1)"
92104
}
93105

94106
if _, err := sess.ID(issue.MilestoneID).
95-
SetExpr("completeness", "num_closed_issues * 100 / num_issues").
96-
NoAutoTime().
107+
SetExpr("completeness", cl+" * 100 / (num_issues + 1)").
108+
NoAutoTime().Cols(cols...).
97109
Update(new(Milestone)); err != nil {
98110
return err
99111
}

models/org.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,12 @@ func (org *User) GetMembers() error {
7272
}
7373

7474
var ids = make([]int64, len(ous))
75+
var idsIsPublic = make(map[int64]bool, len(ous))
7576
for i, ou := range ous {
7677
ids[i] = ou.UID
78+
idsIsPublic[ou.UID] = ou.IsPublic
7779
}
80+
org.MembersIsPublic = idsIsPublic
7881
org.Members, err = GetUsersByIDs(ids)
7982
return err
8083
}
@@ -298,15 +301,13 @@ type OrgUser struct {
298301
}
299302

300303
func isOrganizationOwner(e Engine, orgID, uid int64) (bool, error) {
301-
ownerTeam := &Team{
302-
OrgID: orgID,
303-
Name: ownerTeamName,
304-
}
305-
if has, err := e.Get(ownerTeam); err != nil {
304+
ownerTeam, err := getOwnerTeam(e, orgID)
305+
if err != nil {
306+
if err == ErrTeamNotExist {
307+
log.Error("Organization does not have owner team: %d", orgID)
308+
return false, nil
309+
}
306310
return false, err
307-
} else if !has {
308-
log.Error("Organization does not have owner team: %d", orgID)
309-
return false, nil
310311
}
311312
return isTeamMember(e, orgID, ownerTeam.ID, uid)
312313
}

models/org_team.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,11 @@ func GetTeam(orgID int64, name string) (*Team, error) {
362362
return getTeam(x, orgID, name)
363363
}
364364

365+
// getOwnerTeam returns team by given team name and organization.
366+
func getOwnerTeam(e Engine, orgID int64) (*Team, error) {
367+
return getTeam(e, orgID, ownerTeamName)
368+
}
369+
365370
func getTeamByID(e Engine, teamID int64) (*Team, error) {
366371
t := new(Team)
367372
has, err := e.ID(teamID).Get(t)

models/repo.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1801,6 +1801,7 @@ func DeleteRepository(doer *User, uid, repoID int64) error {
18011801
&HookTask{RepoID: repoID},
18021802
&Notification{RepoID: repoID},
18031803
&CommitStatus{RepoID: repoID},
1804+
&RepoIndexerStatus{RepoID: repoID},
18041805
); err != nil {
18051806
return fmt.Errorf("deleteBeans: %v", err)
18061807
}

0 commit comments

Comments
 (0)