Skip to content

Commit e91843a

Browse files
committed
temp fix
1 parent b0f5f48 commit e91843a

File tree

9 files changed

+30
-17
lines changed

9 files changed

+30
-17
lines changed

modules/context/context_response.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ func (ctx *Context) serverErrorInternal(logMsg string, logErr error) {
166166
// NotFoundOrServerError use error check function to determine if the error
167167
// is about not found. It responds with 404 status code for not found error,
168168
// or error context description for logging purpose of 500 server error.
169+
// TODO: remove the "errCheck" and use util.ErrNotFound to check
169170
func (ctx *Context) NotFoundOrServerError(logMsg string, errCheck func(error) bool, logErr error) {
170171
if errCheck(logErr) {
171172
ctx.notFoundInternal(logMsg, logErr)

modules/git/repo_ref.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,15 @@ func (repo *Repository) GetRefs() ([]*Reference, error) {
1818
// ListOccurrences lists all refs of the given refType the given commit appears in sorted by creation date DESC
1919
// refType should only be a literal "branch" or "tag" and nothing else
2020
func (repo *Repository) ListOccurrences(ctx context.Context, refType, commitSHA string) ([]string, error) {
21-
if refType != "branch" && refType != "tag" {
22-
return nil, util.NewInvalidArgumentErrorf("Can only use branch or 'tag' as 'refType'. Got '%s'", refType)
21+
cmd := NewCommand(ctx)
22+
if refType == "branch" {
23+
cmd.AddArguments("branch")
24+
} else if refType == "tag" {
25+
cmd.AddArguments("tag")
26+
} else {
27+
return nil, util.NewInvalidArgumentErrorf(`can only use "branch" or "tag" for refType, but got %q`, refType)
2328
}
24-
stdout, _, err := NewCommand(ctx, ToTrustedCmdArgs([]string{refType, "--no-color", "--sort=-creatordate", "--contains"})...).AddDynamicArguments(commitSHA).RunStdString(&RunOpts{Dir: repo.Path})
29+
stdout, _, err := cmd.AddArguments("--no-color", "--sort=-creatordate", "--contains").AddDynamicArguments(commitSHA).RunStdString(&RunOpts{Dir: repo.Path})
2530
if err != nil {
2631
return nil, err
2732
}

routers/web/repo/commit.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
"code.gitea.io/gitea/modules/gitgraph"
2323
"code.gitea.io/gitea/modules/log"
2424
"code.gitea.io/gitea/modules/setting"
25-
"code.gitea.io/gitea/modules/util"
2625
"code.gitea.io/gitea/services/gitdiff"
2726
git_service "code.gitea.io/gitea/services/repository"
2827
)
@@ -263,7 +262,7 @@ func LoadBranchesAndTags(ctx *context.Context) {
263262
ctx.JSON(http.StatusOK, response)
264263
return
265264
}
266-
ctx.NotFoundOrServerError(fmt.Sprintf("could not load branches and tags the commit %s belongs to", ctx.Params("sha")), func(err error) bool { return errors.Is(err, util.ErrNotExist) }, err)
265+
ctx.NotFoundOrServerError(fmt.Sprintf("could not load branches and tags the commit %s belongs to", ctx.Params("sha")), git.IsErrNotExist, err)
267266
}
268267

269268
// Diff show different from current commit to previous commit

services/repository/commit.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ type namedLink struct { // TODO: better name?
2323
WebLink string `json:"web_link"`
2424
}
2525

26-
// CreateNewBranch creates a new repository branch
26+
// LoadBranchesAndTags creates a new repository branch
2727
func LoadBranchesAndTags(ctx context.Context, baseRepo *gitea_ctx.Repository, commitSHA string) (*ContainedLinks, error) {
2828
containedTags, err := baseRepo.GitRepo.ListOccurrences(ctx, "tag", commitSHA)
2929
if err != nil {
@@ -35,15 +35,24 @@ func LoadBranchesAndTags(ctx context.Context, baseRepo *gitea_ctx.Repository, co
3535
}
3636

3737
result := &ContainedLinks{
38-
ContainedInDefaultBranch: util.SliceContains(containedBranches, baseRepo.Repository.DefaultBranch), DefaultBranch: baseRepo.Repository.DefaultBranch,
39-
Branches: make([]*namedLink, 0, len(containedBranches)), Tags: make([]*namedLink, 0, len(containedTags)),
38+
ContainedInDefaultBranch: util.SliceContains(containedBranches, baseRepo.Repository.DefaultBranch),
39+
40+
DefaultBranch: baseRepo.Repository.DefaultBranch,
41+
Branches: make([]*namedLink, 0, len(containedBranches)),
42+
Tags: make([]*namedLink, 0, len(containedTags)),
4043
}
4144
for _, tag := range containedTags {
42-
result.Tags = append(result.Tags, &namedLink{Name: tag, WebLink: fmt.Sprintf("%s/src/tag/%s", baseRepo.RepoLink, util.PathEscapeSegments(tag))}) // TODO: Use a common method to get the link to a branch/tag instead of hardcoding it here
45+
// TODO: Use a common method to get the link to a branch/tag instead of hard-coding it here
46+
result.Tags = append(result.Tags, &namedLink{
47+
Name: tag,
48+
WebLink: fmt.Sprintf("%s/src/tag/%s", baseRepo.RepoLink, util.PathEscapeSegments(tag)),
49+
})
4350
}
4451
for _, branch := range containedBranches {
45-
result.Branches = append(result.Branches, &namedLink{Name: branch, WebLink: fmt.Sprintf("%s/src/branch/%s", baseRepo.RepoLink, util.PathEscapeSegments(branch))})
52+
result.Branches = append(result.Branches, &namedLink{
53+
Name: branch,
54+
WebLink: fmt.Sprintf("%s/src/branch/%s", baseRepo.RepoLink, util.PathEscapeSegments(branch)),
55+
})
4656
}
47-
4857
return result, nil
4958
}

templates/repo/commits_list.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
{{end}}
7171
</span>
7272
{{if IsMultilineCommitMessage .Message}}
73-
<button class="ui button ellipsis-js-button ellipsis-button" aria-expanded="false">...</button>
73+
<button class="ui button js-toggle-commit-body ellipsis-button" aria-expanded="false">...</button>
7474
{{end}}
7575
{{template "repo/commit_statuses" dict "Status" .Status "Statuses" .Statuses "root" $}}
7676
{{if IsMultilineCommitMessage .Message}}

templates/repo/commits_list_small.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
<span class="gt-mono commit-summary {{if gt .ParentCount 1}} grey text{{end}}" title="{{.Summary}}">{{RenderCommitMessageLinkSubject $.root.Context .Message ($.comment.Issue.PullRequest.BaseRepo.Link|Escape) $commitLink $.comment.Issue.PullRequest.BaseRepo.ComposeMetas}}</span>
4242
{{if IsMultilineCommitMessage .Message}}
43-
<button class="ui button ellipsis-js-button ellipsis-button" aria-expanded="false">...</button>
43+
<button class="ui button js-toggle-commit-body ellipsis-button" aria-expanded="false">...</button>
4444
{{end}}
4545
{{if IsMultilineCommitMessage .Message}}
4646
<pre class="commit-body gt-hidden">{{RenderCommitBody $.root.Context .Message ($.comment.Issue.PullRequest.BaseRepo.Link|Escape) $.comment.Issue.PullRequest.BaseRepo.ComposeMetas}}</pre>

templates/repo/view_list.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
{{$commitLink:= printf "%s/commit/%s" .RepoLink (PathEscape .LatestCommit.ID.String)}}
2929
<span class="grey commit-summary" title="{{.LatestCommit.Summary}}"><span class="message-wrapper">{{RenderCommitMessageLinkSubject $.Context .LatestCommit.Message $.RepoLink $commitLink $.Repository.ComposeMetas}}</span>
3030
{{if IsMultilineCommitMessage .LatestCommit.Message}}
31-
<button class="ui button ellipsis-js-button ellipsis-button" aria-expanded="false">...</button>
31+
<button class="ui button js-toggle-commit-body ellipsis-button" aria-expanded="false">...</button>
3232
<pre class="commit-body gt-hidden">{{RenderCommitBody $.Context .LatestCommit.Message $.RepoLink $.Repository.ComposeMetas}}</pre>
3333
{{end}}
3434
</span>

web_src/js/features/load-branches-and-tags.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ async function loadBranchesAndTags(loadingButton, addHere) {
1818
const data = await res.json();
1919
showAreas('.branch-tag-area-divider');
2020
loadingButton.classList.add('gt-hidden');
21-
addHere.querySelector('.branch-tag-area-text').textContent =
22-
loadingButton.getAttribute('data-contained-in-text');
21+
addHere.querySelector('.branch-tag-area-text').textContent = loadingButton.getAttribute('data-contained-in-text');
2322
addTags(data.tags, addHere.querySelector('.tag-area'));
2423
const branchArea = addHere.querySelector('.branch-area');
2524
addBranches(

web_src/js/features/repo-commit.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {toggleElem} from '../utils/dom.js';
55
const {csrfToken} = window.config;
66

77
export function initRepoEllipsisButton() {
8-
$('.ellipsis-js-button').on('click', function (e) {
8+
$('.js-toggle-commit-body').on('click', function (e) {
99
e.preventDefault();
1010
const expanded = $(this).attr('aria-expanded') === 'true';
1111
toggleElem($(this).parent().find('.commit-body'));

0 commit comments

Comments
 (0)