mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-27 07:44:43 +02:00
Some improvements
This commit is contained in:
parent
def6e8cc6b
commit
cf3145a4fe
@ -11,6 +11,7 @@ import (
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
"code.gitea.io/gitea/models/unit"
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/gitrepo"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
@ -69,6 +70,8 @@ func CompareDiff(ctx *context.APIContext) {
|
||||
ctx.NotFound("GetRepositoryByOwnerAndName")
|
||||
case errors.Is(err, util.ErrInvalidArgument):
|
||||
ctx.NotFound("ParseComparePathParams")
|
||||
case git.IsErrNotExist(err):
|
||||
ctx.NotFound("ParseComparePathParams")
|
||||
default:
|
||||
ctx.ServerError("GetRepositoryByOwnerAndName", err)
|
||||
}
|
||||
|
@ -417,6 +417,8 @@ func CreatePullRequest(ctx *context.APIContext) {
|
||||
ctx.NotFound("GetRepositoryByOwnerAndName")
|
||||
case errors.Is(err, util.ErrInvalidArgument):
|
||||
ctx.NotFound("ParseComparePathParams")
|
||||
case git.IsErrNotExist(err):
|
||||
ctx.NotFound("ParseComparePathParams")
|
||||
default:
|
||||
ctx.ServerError("GetRepositoryByOwnerAndName", err)
|
||||
}
|
||||
|
@ -30,6 +30,10 @@ func (cr *CompareRouter) DirectComparison() bool {
|
||||
return cr.DotTimes == 2
|
||||
}
|
||||
|
||||
func (cr *CompareRouter) CompareDots() string {
|
||||
return strings.Repeat(".", cr.DotTimes)
|
||||
}
|
||||
|
||||
func parseBase(base string) (string, int) {
|
||||
parts := strings.SplitN(base, "^", 2)
|
||||
if len(parts) == 1 {
|
||||
|
@ -414,6 +414,26 @@ func Test_ParseComparePathParams(t *testing.T) {
|
||||
IsHeadCommit: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
repoName: "repo1",
|
||||
hasClose: true,
|
||||
router: "user12/repo10:master",
|
||||
compareInfo: &CompareInfo{
|
||||
CompareRouter: &CompareRouter{
|
||||
BaseOriRef: repo11.DefaultBranch,
|
||||
BaseFullRef: git.RefNameFromBranch(repo11.DefaultBranch),
|
||||
HeadOwnerName: "user12",
|
||||
HeadRepoName: "repo10",
|
||||
HeadOriRef: "master",
|
||||
HeadFullRef: git.RefNameFromBranch("master"),
|
||||
DotTimes: 3,
|
||||
},
|
||||
BaseRepo: repo1,
|
||||
HeadUser: repo10.Owner,
|
||||
HeadRepo: repo10,
|
||||
HeadGitRepo: gitRepo10,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, kase := range kases {
|
||||
|
@ -554,11 +554,8 @@ func CompareDiff(ctx *context.Context) {
|
||||
}
|
||||
beforeCommitID := ctx.Data["BeforeCommitID"].(string)
|
||||
afterCommitID := ctx.Data["AfterCommitID"].(string)
|
||||
separator := ci.CompareDots()
|
||||
|
||||
separator := "..."
|
||||
if ci.DirectComparison() {
|
||||
separator = ".."
|
||||
}
|
||||
ctx.Data["Title"] = "Comparing " + base.ShortSha(beforeCommitID) + separator + base.ShortSha(afterCommitID)
|
||||
|
||||
ctx.Data["IsDiffCompare"] = true
|
||||
|
Loading…
x
Reference in New Issue
Block a user