Skip to content

Commit fa2786a

Browse files
committed
Merge branch 'release/v1.8' of git://github.com/go-gitea/gitea into wild/v1.8
2 parents f7761fb + e94a842 commit fa2786a

File tree

8 files changed

+233
-130
lines changed

8 files changed

+233
-130
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ This changelog goes through all the changes that have been made in each release
44
without substantial changes to our git log; to see the highlights of what has
55
been added to each release, please refer to the [blog](https://blog.gitea.io).
66

7+
## [1.8.3](https://github.com/go-gitea/gitea/releases/tag/v1.8.3) - 2019-06-17
8+
* BUGFIXES
9+
* Always set userID on LFS authentication (#7224) (Part of #6993)
10+
* Fix LFS Locks over SSH (#6999) (#7223)
11+
* Fix duplicated file on pull request conflicted files (#7211) (#7214)
12+
* Detect noreply email address as user (#7133) (#7195)
13+
* Don't get milestone from DB if ID is zero (#7169) (#7174)
14+
* Allow archived repos to be (un)starred and (un)watched (#7163) (#7168)
15+
* Fix GCArgs load from ini (#7156) (#7157)
16+
717
## [1.8.2](https://github.com/go-gitea/gitea/releases/tag/v1.8.2) - 2019-05-29
818
* BUGFIXES
919
* Fix possbile mysql invalid connnection error (#7051) (#7071)

cmd/serv.go

Lines changed: 61 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -217,75 +217,77 @@ func runServ(c *cli.Context) error {
217217

218218
// Allow anonymous clone for public repositories.
219219
var (
220-
keyID int64
221-
user *models.User
220+
keyID int64
221+
user *models.User
222+
userID int64
222223
)
223-
if requestedMode == models.AccessModeWrite || repo.IsPrivate || setting.Service.RequireSignInView {
224-
keys := strings.Split(c.Args()[0], "-")
225-
if len(keys) != 2 {
226-
fail("Key ID format error", "Invalid key argument: %s", c.Args()[0])
227-
}
228224

229-
key, err := private.GetPublicKeyByID(com.StrTo(keys[1]).MustInt64())
225+
keys := strings.Split(c.Args()[0], "-")
226+
if len(keys) != 2 {
227+
fail("Key ID format error", "Invalid key argument: %s", c.Args()[0])
228+
}
229+
230+
key, err := private.GetPublicKeyByID(com.StrTo(keys[1]).MustInt64())
231+
if err != nil {
232+
fail("Invalid key ID", "Invalid key ID[%s]: %v", c.Args()[0], err)
233+
}
234+
keyID = key.ID
235+
userID = key.OwnerID
236+
237+
if key.Type == models.KeyTypeDeploy {
238+
// Now we have to get the deploy key for this repo
239+
deployKey, err := private.GetDeployKey(key.ID, repo.ID)
230240
if err != nil {
231-
fail("Invalid key ID", "Invalid key ID[%s]: %v", c.Args()[0], err)
241+
fail("Key access denied", "Failed to access internal api: [key_id: %d, repo_id: %d]", key.ID, repo.ID)
232242
}
233-
keyID = key.ID
234243

235-
// Check deploy key or user key.
236-
if key.Type == models.KeyTypeDeploy {
237-
// Now we have to get the deploy key for this repo
238-
deployKey, err := private.GetDeployKey(key.ID, repo.ID)
239-
if err != nil {
240-
fail("Key access denied", "Failed to access internal api: [key_id: %d, repo_id: %d]", key.ID, repo.ID)
241-
}
242-
243-
if deployKey == nil {
244-
fail("Key access denied", "Deploy key access denied: [key_id: %d, repo_id: %d]", key.ID, repo.ID)
245-
}
244+
if deployKey == nil {
245+
fail("Key access denied", "Deploy key access denied: [key_id: %d, repo_id: %d]", key.ID, repo.ID)
246+
}
246247

247-
if deployKey.Mode < requestedMode {
248-
fail("Key permission denied", "Cannot push with read-only deployment key: %d to repo_id: %d", key.ID, repo.ID)
249-
}
248+
if deployKey.Mode < requestedMode {
249+
fail("Key permission denied", "Cannot push with read-only deployment key: %d to repo_id: %d", key.ID, repo.ID)
250+
}
250251

251-
// Update deploy key activity.
252-
if err = private.UpdateDeployKeyUpdated(key.ID, repo.ID); err != nil {
253-
fail("Internal error", "UpdateDeployKey: %v", err)
254-
}
252+
// Update deploy key activity.
253+
if err = private.UpdateDeployKeyUpdated(key.ID, repo.ID); err != nil {
254+
fail("Internal error", "UpdateDeployKey: %v", err)
255+
}
255256

256-
// FIXME: Deploy keys aren't really the owner of the repo pushing changes
257-
// however we don't have good way of representing deploy keys in hook.go
258-
// so for now use the owner
259-
os.Setenv(models.EnvPusherName, username)
260-
os.Setenv(models.EnvPusherID, fmt.Sprintf("%d", repo.OwnerID))
261-
} else {
262-
user, err = private.GetUserByKeyID(key.ID)
263-
if err != nil {
264-
fail("internal error", "Failed to get user by key ID(%d): %v", keyID, err)
265-
}
257+
// FIXME: Deploy keys aren't really the owner of the repo pushing changes
258+
// however we don't have good way of representing deploy keys in hook.go
259+
// so for now use the owner
260+
os.Setenv(models.EnvPusherName, username)
261+
os.Setenv(models.EnvPusherID, fmt.Sprintf("%d", repo.OwnerID))
262+
userID = repo.OwnerID
263+
} else if requestedMode == models.AccessModeWrite || repo.IsPrivate || setting.Service.RequireSignInView {
264+
// Check deploy key or user key.
265+
user, err = private.GetUserByKeyID(key.ID)
266+
if err != nil {
267+
fail("internal error", "Failed to get user by key ID(%d): %v", keyID, err)
268+
}
266269

267-
if !user.IsActive || user.ProhibitLogin {
268-
fail("Your account is not active or has been disabled by Administrator",
269-
"User %s is disabled and have no access to repository %s",
270-
user.Name, repoPath)
271-
}
270+
if !user.IsActive || user.ProhibitLogin {
271+
fail("Your account is not active or has been disabled by Administrator",
272+
"User %s is disabled and have no access to repository %s",
273+
user.Name, repoPath)
274+
}
272275

273-
mode, err := private.CheckUnitUser(user.ID, repo.ID, user.IsAdmin, unitType)
274-
if err != nil {
275-
fail("Internal error", "Failed to check access: %v", err)
276-
} else if *mode < requestedMode {
277-
clientMessage := accessDenied
278-
if *mode >= models.AccessModeRead {
279-
clientMessage = "You do not have sufficient authorization for this action"
280-
}
281-
fail(clientMessage,
282-
"User %s does not have level %v access to repository %s's "+unitName,
283-
user.Name, requestedMode, repoPath)
276+
mode, err := private.CheckUnitUser(user.ID, repo.ID, user.IsAdmin, unitType)
277+
if err != nil {
278+
fail("Internal error", "Failed to check access: %v", err)
279+
} else if *mode < requestedMode {
280+
clientMessage := accessDenied
281+
if *mode >= models.AccessModeRead {
282+
clientMessage = "You do not have sufficient authorization for this action"
284283
}
285-
286-
os.Setenv(models.EnvPusherName, user.Name)
287-
os.Setenv(models.EnvPusherID, fmt.Sprintf("%d", user.ID))
284+
fail(clientMessage,
285+
"User %s does not have level %v access to repository %s's "+unitName,
286+
user.Name, requestedMode, repoPath)
288287
}
288+
289+
os.Setenv(models.EnvPusherName, user.Name)
290+
os.Setenv(models.EnvPusherID, fmt.Sprintf("%d", user.ID))
289291
}
290292

291293
//LFS token authentication
@@ -299,8 +301,8 @@ func runServ(c *cli.Context) error {
299301
"exp": now.Add(setting.LFS.HTTPAuthExpiry).Unix(),
300302
"nbf": now.Unix(),
301303
}
302-
if user != nil {
303-
claims["user"] = user.ID
304+
if userID > 0 {
305+
claims["user"] = userID
304306
}
305307
token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
306308

integrations/git_test.go

Lines changed: 65 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ func testGit(t *testing.T, u *url.URL) {
6161
little = commitAndPush(t, littleSize, dstPath)
6262
})
6363
t.Run("Big", func(t *testing.T) {
64+
if testing.Short() {
65+
t.Skip("skipping test in short mode.")
66+
return
67+
}
6468
big = commitAndPush(t, bigSize, dstPath)
6569
})
6670
})
@@ -77,9 +81,15 @@ func testGit(t *testing.T, u *url.URL) {
7781

7882
t.Run("Little", func(t *testing.T) {
7983
littleLFS = commitAndPush(t, littleSize, dstPath)
84+
lockFileTest(t, littleLFS, dstPath)
8085
})
8186
t.Run("Big", func(t *testing.T) {
87+
if testing.Short() {
88+
t.Skip("skipping test in short mode.")
89+
return
90+
}
8291
bigLFS = commitAndPush(t, bigSize, dstPath)
92+
lockFileTest(t, bigLFS, dstPath)
8393
})
8494
})
8595
t.Run("Locks", func(t *testing.T) {
@@ -94,19 +104,21 @@ func testGit(t *testing.T, u *url.URL) {
94104
resp := session.MakeRequest(t, req, http.StatusOK)
95105
assert.Equal(t, littleSize, resp.Body.Len())
96106

97-
req = NewRequest(t, "GET", path.Join("/user2/repo-tmp-17/raw/branch/master/", big))
98-
nilResp := session.MakeRequestNilResponseRecorder(t, req, http.StatusOK)
99-
assert.Equal(t, bigSize, nilResp.Length)
100-
101107
req = NewRequest(t, "GET", path.Join("/user2/repo-tmp-17/raw/branch/master/", littleLFS))
102108
resp = session.MakeRequest(t, req, http.StatusOK)
103109
assert.NotEqual(t, littleSize, resp.Body.Len())
104110
assert.Contains(t, resp.Body.String(), models.LFSMetaFileIdentifier)
105111

106-
req = NewRequest(t, "GET", path.Join("/user2/repo-tmp-17/raw/branch/master/", bigLFS))
107-
resp = session.MakeRequest(t, req, http.StatusOK)
108-
assert.NotEqual(t, bigSize, resp.Body.Len())
109-
assert.Contains(t, resp.Body.String(), models.LFSMetaFileIdentifier)
112+
if !testing.Short() {
113+
req = NewRequest(t, "GET", path.Join("/user2/repo-tmp-17/raw/branch/master/", big))
114+
nilResp := session.MakeRequestNilResponseRecorder(t, req, http.StatusOK)
115+
assert.Equal(t, bigSize, nilResp.Length)
116+
117+
req = NewRequest(t, "GET", path.Join("/user2/repo-tmp-17/raw/branch/master/", bigLFS))
118+
resp = session.MakeRequest(t, req, http.StatusOK)
119+
assert.NotEqual(t, bigSize, resp.Body.Len())
120+
assert.Contains(t, resp.Body.String(), models.LFSMetaFileIdentifier)
121+
}
110122

111123
})
112124
t.Run("Media", func(t *testing.T) {
@@ -117,17 +129,19 @@ func testGit(t *testing.T, u *url.URL) {
117129
resp := session.MakeRequestNilResponseRecorder(t, req, http.StatusOK)
118130
assert.Equal(t, littleSize, resp.Length)
119131

120-
req = NewRequest(t, "GET", path.Join("/user2/repo-tmp-17/media/branch/master/", big))
121-
resp = session.MakeRequestNilResponseRecorder(t, req, http.StatusOK)
122-
assert.Equal(t, bigSize, resp.Length)
123-
124132
req = NewRequest(t, "GET", path.Join("/user2/repo-tmp-17/media/branch/master/", littleLFS))
125133
resp = session.MakeRequestNilResponseRecorder(t, req, http.StatusOK)
126134
assert.Equal(t, littleSize, resp.Length)
127135

128-
req = NewRequest(t, "GET", path.Join("/user2/repo-tmp-17/media/branch/master/", bigLFS))
129-
resp = session.MakeRequestNilResponseRecorder(t, req, http.StatusOK)
130-
assert.Equal(t, bigSize, resp.Length)
136+
if !testing.Short() {
137+
req = NewRequest(t, "GET", path.Join("/user2/repo-tmp-17/media/branch/master/", big))
138+
resp = session.MakeRequestNilResponseRecorder(t, req, http.StatusOK)
139+
assert.Equal(t, bigSize, resp.Length)
140+
141+
req = NewRequest(t, "GET", path.Join("/user2/repo-tmp-17/media/branch/master/", bigLFS))
142+
resp = session.MakeRequestNilResponseRecorder(t, req, http.StatusOK)
143+
assert.Equal(t, bigSize, resp.Length)
144+
}
131145
})
132146

133147
})
@@ -160,6 +174,10 @@ func testGit(t *testing.T, u *url.URL) {
160174
little = commitAndPush(t, littleSize, dstPath)
161175
})
162176
t.Run("Big", func(t *testing.T) {
177+
if testing.Short() {
178+
t.Skip("skipping test in short mode.")
179+
return
180+
}
163181
big = commitAndPush(t, bigSize, dstPath)
164182
})
165183
})
@@ -176,9 +194,16 @@ func testGit(t *testing.T, u *url.URL) {
176194

177195
t.Run("Little", func(t *testing.T) {
178196
littleLFS = commitAndPush(t, littleSize, dstPath)
197+
lockFileTest(t, littleLFS, dstPath)
198+
179199
})
180200
t.Run("Big", func(t *testing.T) {
201+
if testing.Short() {
202+
return
203+
}
181204
bigLFS = commitAndPush(t, bigSize, dstPath)
205+
lockFileTest(t, bigLFS, dstPath)
206+
182207
})
183208
})
184209
t.Run("Locks", func(t *testing.T) {
@@ -193,20 +218,21 @@ func testGit(t *testing.T, u *url.URL) {
193218
resp := session.MakeRequest(t, req, http.StatusOK)
194219
assert.Equal(t, littleSize, resp.Body.Len())
195220

196-
req = NewRequest(t, "GET", path.Join("/user2/repo-tmp-18/raw/branch/master/", big))
197-
resp = session.MakeRequest(t, req, http.StatusOK)
198-
assert.Equal(t, bigSize, resp.Body.Len())
199-
200221
req = NewRequest(t, "GET", path.Join("/user2/repo-tmp-18/raw/branch/master/", littleLFS))
201222
resp = session.MakeRequest(t, req, http.StatusOK)
202223
assert.NotEqual(t, littleSize, resp.Body.Len())
203224
assert.Contains(t, resp.Body.String(), models.LFSMetaFileIdentifier)
204225

205-
req = NewRequest(t, "GET", path.Join("/user2/repo-tmp-18/raw/branch/master/", bigLFS))
206-
resp = session.MakeRequest(t, req, http.StatusOK)
207-
assert.NotEqual(t, bigSize, resp.Body.Len())
208-
assert.Contains(t, resp.Body.String(), models.LFSMetaFileIdentifier)
226+
if !testing.Short() {
227+
req = NewRequest(t, "GET", path.Join("/user2/repo-tmp-18/raw/branch/master/", big))
228+
resp = session.MakeRequest(t, req, http.StatusOK)
229+
assert.Equal(t, bigSize, resp.Body.Len())
209230

231+
req = NewRequest(t, "GET", path.Join("/user2/repo-tmp-18/raw/branch/master/", bigLFS))
232+
resp = session.MakeRequest(t, req, http.StatusOK)
233+
assert.NotEqual(t, bigSize, resp.Body.Len())
234+
assert.Contains(t, resp.Body.String(), models.LFSMetaFileIdentifier)
235+
}
210236
})
211237
t.Run("Media", func(t *testing.T) {
212238
session := loginUser(t, "user2")
@@ -216,17 +242,19 @@ func testGit(t *testing.T, u *url.URL) {
216242
resp := session.MakeRequest(t, req, http.StatusOK)
217243
assert.Equal(t, littleSize, resp.Body.Len())
218244

219-
req = NewRequest(t, "GET", path.Join("/user2/repo-tmp-18/media/branch/master/", big))
220-
resp = session.MakeRequest(t, req, http.StatusOK)
221-
assert.Equal(t, bigSize, resp.Body.Len())
222-
223245
req = NewRequest(t, "GET", path.Join("/user2/repo-tmp-18/media/branch/master/", littleLFS))
224246
resp = session.MakeRequest(t, req, http.StatusOK)
225247
assert.Equal(t, littleSize, resp.Body.Len())
226248

227-
req = NewRequest(t, "GET", path.Join("/user2/repo-tmp-18/media/branch/master/", bigLFS))
228-
resp = session.MakeRequest(t, req, http.StatusOK)
229-
assert.Equal(t, bigSize, resp.Body.Len())
249+
if !testing.Short() {
250+
req = NewRequest(t, "GET", path.Join("/user2/repo-tmp-18/media/branch/master/", big))
251+
resp = session.MakeRequest(t, req, http.StatusOK)
252+
assert.Equal(t, bigSize, resp.Body.Len())
253+
254+
req = NewRequest(t, "GET", path.Join("/user2/repo-tmp-18/media/branch/master/", bigLFS))
255+
resp = session.MakeRequest(t, req, http.StatusOK)
256+
assert.Equal(t, bigSize, resp.Body.Len())
257+
}
230258
})
231259

232260
})
@@ -243,15 +271,17 @@ func ensureAnonymousClone(t *testing.T, u *url.URL) {
243271
}
244272

245273
func lockTest(t *testing.T, remote, repoPath string) {
246-
_, err := git.NewCommand("remote").AddArguments("set-url", "origin", remote).RunInDir(repoPath) //TODO add test ssh git-lfs-creds
247-
assert.NoError(t, err)
248-
_, err = git.NewCommand("lfs").AddArguments("locks").RunInDir(repoPath)
274+
lockFileTest(t, "README.md", repoPath)
275+
}
276+
277+
func lockFileTest(t *testing.T, filename, repoPath string) {
278+
_, err := git.NewCommand("lfs").AddArguments("locks").RunInDir(repoPath)
249279
assert.NoError(t, err)
250-
_, err = git.NewCommand("lfs").AddArguments("lock", "README.md").RunInDir(repoPath)
280+
_, err = git.NewCommand("lfs").AddArguments("lock", filename).RunInDir(repoPath)
251281
assert.NoError(t, err)
252282
_, err = git.NewCommand("lfs").AddArguments("locks").RunInDir(repoPath)
253283
assert.NoError(t, err)
254-
_, err = git.NewCommand("lfs").AddArguments("unlock", "README.md").RunInDir(repoPath)
284+
_, err = git.NewCommand("lfs").AddArguments("unlock", filename).RunInDir(repoPath)
255285
assert.NoError(t, err)
256286
}
257287

models/pull.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,17 @@ func (pr *PullRequest) testPatch(e Engine) (err error) {
861861
line := scanner.Text()
862862

863863
if strings.HasPrefix(line, prefix) {
864-
pr.ConflictedFiles = append(pr.ConflictedFiles, strings.TrimSpace(strings.Split(line[len(prefix):], ":")[0]))
864+
var found bool
865+
var filepath = strings.TrimSpace(strings.Split(line[len(prefix):], ":")[0])
866+
for _, f := range pr.ConflictedFiles {
867+
if f == filepath {
868+
found = true
869+
break
870+
}
871+
}
872+
if !found {
873+
pr.ConflictedFiles = append(pr.ConflictedFiles, filepath)
874+
}
865875
}
866876
// only list 10 conflicted files
867877
if len(pr.ConflictedFiles) >= 10 {

0 commit comments

Comments
 (0)