diff options
author | KN4CK3R <admin@oldschoolhack.me> | 2021-11-18 00:50:17 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-17 23:50:17 +0000 |
commit | ea42d3c04ef48b9ff0354ea196179d1a5025c04a (patch) | |
tree | 8a95df877dae7a5cf62364a525cc532205d5d188 /routers | |
parent | 3c4724d70e4ac7bfc06b97f6fad8936f97479b6b (diff) | |
download | gitea-ea42d3c04ef48b9ff0354ea196179d1a5025c04a.tar.gz gitea-ea42d3c04ef48b9ff0354ea196179d1a5025c04a.zip |
Fixed commit count. (#17698)
Added "Tag" label.
Unified branch, tag and commit name.
Diffstat (limited to 'routers')
-rw-r--r-- | routers/web/repo/branch.go | 12 | ||||
-rw-r--r-- | routers/web/repo/commit.go | 13 | ||||
-rw-r--r-- | routers/web/repo/view.go | 2 |
3 files changed, 12 insertions, 15 deletions
diff --git a/routers/web/repo/branch.go b/routers/web/repo/branch.go index 10557ff3db..27cd06023d 100644 --- a/routers/web/repo/branch.go +++ b/routers/web/repo/branch.go @@ -344,17 +344,15 @@ func CreateBranch(ctx *context.Context) { var err error if form.CreateTag { - if ctx.Repo.IsViewTag { - err = release_service.CreateNewTag(ctx.User, ctx.Repo.Repository, ctx.Repo.CommitID, form.NewBranchName, "") - } else { - err = release_service.CreateNewTag(ctx.User, ctx.Repo.Repository, ctx.Repo.BranchName, form.NewBranchName, "") + target := ctx.Repo.CommitID + if ctx.Repo.IsViewBranch { + target = ctx.Repo.BranchName } + err = release_service.CreateNewTag(ctx.User, ctx.Repo.Repository, target, form.NewBranchName, "") } else if ctx.Repo.IsViewBranch { err = repo_service.CreateNewBranch(ctx.User, ctx.Repo.Repository, ctx.Repo.BranchName, form.NewBranchName) - } else if ctx.Repo.IsViewTag { - err = repo_service.CreateNewBranchFromCommit(ctx.User, ctx.Repo.Repository, ctx.Repo.CommitID, form.NewBranchName) } else { - err = repo_service.CreateNewBranchFromCommit(ctx.User, ctx.Repo.Repository, ctx.Repo.BranchName, form.NewBranchName) + err = repo_service.CreateNewBranchFromCommit(ctx.User, ctx.Repo.Repository, ctx.Repo.CommitID, form.NewBranchName) } if err != nil { if models.IsErrTagAlreadyExists(err) { diff --git a/routers/web/repo/commit.go b/routers/web/repo/commit.go index 06cce92417..c9e2b94f23 100644 --- a/routers/web/repo/commit.go +++ b/routers/web/repo/commit.go @@ -77,7 +77,7 @@ func Commits(ctx *context.Context) { ctx.Data["Username"] = ctx.Repo.Owner.Name ctx.Data["Reponame"] = ctx.Repo.Repository.Name ctx.Data["CommitCount"] = commitsCount - ctx.Data["Branch"] = ctx.Repo.BranchName + ctx.Data["RefName"] = ctx.Repo.RefName pager := context.NewPagination(int(commitsCount), setting.Git.CommitsRangeSize, page, 5) pager.SetDefaultParams(ctx) @@ -153,7 +153,7 @@ func Graph(ctx *context.Context) { ctx.Data["Username"] = ctx.Repo.Owner.Name ctx.Data["Reponame"] = ctx.Repo.Repository.Name ctx.Data["CommitCount"] = commitsCount - ctx.Data["Branch"] = ctx.Repo.BranchName + ctx.Data["RefName"] = ctx.Repo.RefName paginator := context.NewPagination(int(graphCommitsCount), setting.UI.GraphMaxCommitNum, page, 5) paginator.AddParam(ctx, "mode", "Mode") paginator.AddParam(ctx, "hide-pr-refs", "HidePRRefs") @@ -199,7 +199,7 @@ func SearchCommits(ctx *context.Context) { } ctx.Data["Username"] = ctx.Repo.Owner.Name ctx.Data["Reponame"] = ctx.Repo.Repository.Name - ctx.Data["Branch"] = ctx.Repo.BranchName + ctx.Data["RefName"] = ctx.Repo.RefName ctx.HTML(http.StatusOK, tplCommits) } @@ -213,8 +213,7 @@ func FileHistory(ctx *context.Context) { return } - branchName := ctx.Repo.BranchName - commitsCount, err := ctx.Repo.GitRepo.FileCommitsCount(branchName, fileName) + commitsCount, err := ctx.Repo.GitRepo.FileCommitsCount(ctx.Repo.RefName, fileName) if err != nil { ctx.ServerError("FileCommitsCount", err) return @@ -228,7 +227,7 @@ func FileHistory(ctx *context.Context) { page = 1 } - commits, err := ctx.Repo.GitRepo.CommitsByFileAndRange(branchName, fileName, page) + commits, err := ctx.Repo.GitRepo.CommitsByFileAndRange(ctx.Repo.RefName, fileName, page) if err != nil { ctx.ServerError("CommitsByFileAndRange", err) return @@ -239,7 +238,7 @@ func FileHistory(ctx *context.Context) { ctx.Data["Reponame"] = ctx.Repo.Repository.Name ctx.Data["FileName"] = fileName ctx.Data["CommitCount"] = commitsCount - ctx.Data["Branch"] = branchName + ctx.Data["RefName"] = ctx.Repo.RefName pager := context.NewPagination(int(commitsCount), setting.Git.CommitsRangeSize, page, 5) pager.SetDefaultParams(ctx) diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go index 938292a37a..d455dc1039 100644 --- a/routers/web/repo/view.go +++ b/routers/web/repo/view.go @@ -371,7 +371,7 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st } defer dataRc.Close() - ctx.Data["Title"] = ctx.Data["Title"].(string) + " - " + ctx.Repo.TreePath + " at " + ctx.Repo.BranchName + ctx.Data["Title"] = ctx.Data["Title"].(string) + " - " + ctx.Tr("repo.file.title", ctx.Repo.TreePath, ctx.Repo.RefName) fileSize := blob.Size() ctx.Data["FileIsSymlink"] = entry.IsLink() |