Skip to content

Commit a2c8e9c

Browse files
committed
Fix test
1 parent 3c51f38 commit a2c8e9c

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

routers/api/v1/repo/pull.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,12 +1077,12 @@ func parseCompareInfo(ctx *context.APIContext, compareParam string) (result *par
10771077

10781078
var headRepo *repo_model.Repository
10791079
if compareReq.HeadOwner == "" {
1080-
if compareReq.HeadRepoName == "" {
1081-
headRepo = ctx.Repo.Repository
1082-
} else {
1080+
if compareReq.HeadRepoName != "" { // unsupported syntax
10831081
ctx.APIErrorNotFound()
10841082
return nil, nil
10851083
}
1084+
1085+
headRepo = ctx.Repo.Repository
10861086
} else {
10871087
var headUser *user_model.User
10881088
if compareReq.HeadOwner == ctx.Repo.Owner.Name {

routers/web/repo/compare.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -204,18 +204,18 @@ func ParseCompareInfo(ctx *context.Context) *common.CompareInfo {
204204
}
205205

206206
if compareReq.HeadOwner == "" {
207-
if compareReq.HeadRepoName == "" {
208-
ci.HeadRepo = baseRepo
209-
} else {
207+
if compareReq.HeadRepoName != "" { // unsupported syntax
210208
ctx.NotFound(nil)
211209
return nil
212210
}
211+
212+
ci.HeadUser = baseRepo.Owner
213+
ci.HeadRepo = baseRepo
213214
} else {
214-
var headUser *user_model.User
215215
if compareReq.HeadOwner == ctx.Repo.Owner.Name {
216-
headUser = ctx.Repo.Owner
216+
ci.HeadUser = ctx.Repo.Owner
217217
} else {
218-
headUser, err = user_model.GetUserByName(ctx, compareReq.HeadOwner)
218+
ci.HeadUser, err = user_model.GetUserByName(ctx, compareReq.HeadOwner)
219219
if err != nil {
220220
if user_model.IsErrUserNotExist(err) {
221221
ctx.NotFound(nil)
@@ -226,16 +226,16 @@ func ParseCompareInfo(ctx *context.Context) *common.CompareInfo {
226226
}
227227
}
228228
if compareReq.HeadRepoName == "" {
229-
ci.HeadRepo = repo_model.GetForkedRepo(ctx, headUser.ID, baseRepo.ID)
230-
if ci.HeadRepo == nil && headUser.ID != baseRepo.OwnerID {
229+
ci.HeadRepo = repo_model.GetForkedRepo(ctx, ci.HeadUser.ID, baseRepo.ID)
230+
if ci.HeadRepo == nil && ci.HeadUser.ID != baseRepo.OwnerID {
231231
err = baseRepo.GetBaseRepo(ctx)
232232
if err != nil {
233233
ctx.ServerError("GetBaseRepo", err)
234234
return nil
235235
}
236236

237237
// Check if baseRepo's base repository is the same as headUser's repository.
238-
if baseRepo.BaseRepo == nil || baseRepo.BaseRepo.OwnerID != headUser.ID {
238+
if baseRepo.BaseRepo == nil || baseRepo.BaseRepo.OwnerID != ci.HeadUser.ID {
239239
log.Trace("parseCompareInfo[%d]: does not have fork or in same repository", baseRepo.ID)
240240
ctx.NotFound(nil)
241241
return nil
@@ -247,7 +247,7 @@ func ParseCompareInfo(ctx *context.Context) *common.CompareInfo {
247247
if compareReq.HeadOwner == ctx.Repo.Owner.Name && compareReq.HeadRepoName == ctx.Repo.Repository.Name {
248248
ci.HeadRepo = ctx.Repo.Repository
249249
} else {
250-
ci.HeadRepo, err = repo_model.GetRepositoryByName(ctx, headUser.ID, compareReq.HeadRepoName)
250+
ci.HeadRepo, err = repo_model.GetRepositoryByName(ctx, ci.HeadUser.ID, compareReq.HeadRepoName)
251251
if err != nil {
252252
if repo_model.IsErrRepoNotExist(err) {
253253
ctx.NotFound(nil)

0 commit comments

Comments
 (0)