mirror of
https://codeberg.org/forgejo/forgejo
synced 2024-11-22 01:44:24 +01:00
fmt
This commit is contained in:
parent
1b9d1240eb
commit
01c9c19536
|
@ -1113,16 +1113,16 @@ func parseCompareInfo(ctx *context.APIContext, form api.CreatePullRequestOption)
|
||||||
|
|
||||||
// Check if base branch is valid.
|
// Check if base branch is valid.
|
||||||
baseIsCommit := ctx.Repo.GitRepo.IsCommitExist(baseBranch)
|
baseIsCommit := ctx.Repo.GitRepo.IsCommitExist(baseBranch)
|
||||||
baseIsBranch := ctx.Repo.GitRepo.IsBranchExist(baseBranch)
|
baseIsBranch := ctx.Repo.GitRepo.IsBranchExist(baseBranch)
|
||||||
baseIsTag := ctx.Repo.GitRepo.IsTagExist(baseBranch)
|
baseIsTag := ctx.Repo.GitRepo.IsTagExist(baseBranch)
|
||||||
if !baseIsCommit && !baseIsBranch && !baseIsTag {
|
if !baseIsCommit && !baseIsBranch && !baseIsTag {
|
||||||
// Check for short SHA usage
|
// Check for short SHA usage
|
||||||
if baseCommit, _ := ctx.Repo.GitRepo.GetCommit(baseBranch); baseCommit != nil {
|
if baseCommit, _ := ctx.Repo.GitRepo.GetCommit(baseBranch); baseCommit != nil {
|
||||||
baseBranch = baseCommit.ID.String()
|
baseBranch = baseCommit.ID.String()
|
||||||
} else {
|
} else {
|
||||||
ctx.NotFound("BaseNotExist")
|
ctx.NotFound("BaseNotExist")
|
||||||
return nil, nil, nil, "", ""
|
return nil, nil, nil, "", ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if current user has fork of repository or in the same repository.
|
// Check if current user has fork of repository or in the same repository.
|
||||||
|
@ -1197,30 +1197,30 @@ func parseCompareInfo(ctx *context.APIContext, form api.CreatePullRequestOption)
|
||||||
// Check if head branch is valid.
|
// Check if head branch is valid.
|
||||||
headIsCommit := headGitRepo.IsBranchExist(headBranch)
|
headIsCommit := headGitRepo.IsBranchExist(headBranch)
|
||||||
headIsBranch := headGitRepo.IsTagExist(headBranch)
|
headIsBranch := headGitRepo.IsTagExist(headBranch)
|
||||||
headIsTag := headGitRepo.IsCommitExist(baseBranch)
|
headIsTag := headGitRepo.IsCommitExist(baseBranch)
|
||||||
if !headIsCommit && !headIsBranch && !headIsTag {
|
if !headIsCommit && !headIsBranch && !headIsTag {
|
||||||
// Check if headBranch is short sha commit hash
|
// Check if headBranch is short sha commit hash
|
||||||
if headCommit, _ := headGitRepo.GetCommit(headBranch); headCommit != nil {
|
if headCommit, _ := headGitRepo.GetCommit(headBranch); headCommit != nil {
|
||||||
headBranch = headCommit.ID.String()
|
headBranch = headCommit.ID.String()
|
||||||
} else {
|
} else {
|
||||||
headGitRepo.Close()
|
headGitRepo.Close()
|
||||||
ctx.NotFound("IsRefExist", nil)
|
ctx.NotFound("IsRefExist", nil)
|
||||||
return nil, nil, nil, "", ""
|
return nil, nil, nil, "", ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
baseBranchRef := baseBranch
|
baseBranchRef := baseBranch
|
||||||
if baseIsBranch {
|
if baseIsBranch {
|
||||||
baseBranchRef = git.BranchPrefix + baseBranch
|
baseBranchRef = git.BranchPrefix + baseBranch
|
||||||
} else if baseIsTag {
|
} else if baseIsTag {
|
||||||
baseBranchRef = git.TagPrefix + baseBranch
|
baseBranchRef = git.TagPrefix + baseBranch
|
||||||
}
|
}
|
||||||
headBranchRef := headBranch
|
headBranchRef := headBranch
|
||||||
if headIsBranch {
|
if headIsBranch {
|
||||||
headBranchRef = headBranch
|
headBranchRef = headBranch
|
||||||
} else if headIsTag {
|
} else if headIsTag {
|
||||||
headBranchRef = headBranch
|
headBranchRef = headBranch
|
||||||
}
|
}
|
||||||
|
|
||||||
compareInfo, err := headGitRepo.GetCompareInfo(repo_model.RepoPath(baseRepo.Owner.Name, baseRepo.Name), baseBranchRef, headBranchRef, false, false)
|
compareInfo, err := headGitRepo.GetCompareInfo(repo_model.RepoPath(baseRepo.Owner.Name, baseRepo.Name), baseBranchRef, headBranchRef, false, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -56,4 +56,4 @@ func TestAPICompareCommits(t *testing.T) {
|
||||||
|
|
||||||
assert.Equal(t, 2, apiResp.TotalCommits)
|
assert.Equal(t, 2, apiResp.TotalCommits)
|
||||||
assert.Len(t, apiResp.Commits, 2)
|
assert.Len(t, apiResp.Commits, 2)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue