Skip to content

Commit

Permalink
Merge branch 'main' into add-missing-repo-units
Browse files Browse the repository at this point in the history
  • Loading branch information
jolheiser authored Mar 16, 2023
2 parents 9cabda9 + 8d9f8e1 commit e15d400
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 36 deletions.
22 changes: 22 additions & 0 deletions models/repo/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,28 @@ func GetReleasesByRepoID(ctx context.Context, repoID int64, opts FindReleasesOpt
return rels, sess.Find(&rels)
}

// GetTagNamesByRepoID returns a list of release tag names of repository.
func GetTagNamesByRepoID(ctx context.Context, repoID int64) ([]string, error) {
listOptions := db.ListOptions{
ListAll: true,
}
opts := FindReleasesOptions{
ListOptions: listOptions,
IncludeDrafts: true,
IncludeTags: true,
HasSha1: util.OptionalBoolTrue,
}

tags := make([]string, 0)
sess := db.GetEngine(ctx).
Table("release").
Desc("created_unix", "id").
Where(opts.toConds(repoID)).
Cols("tag_name")

return tags, sess.Find(&tags)
}

// CountReleasesByRepoID returns a number of releases matching FindReleaseOptions and RepoID.
func CountReleasesByRepoID(repoID int64, opts FindReleasesOptions) (int64, error) {
return db.GetEngine(db.DefaultContext).Where(opts.toConds(repoID)).Count(new(Release))
Expand Down
15 changes: 2 additions & 13 deletions modules/context/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -660,20 +660,9 @@ func RepoAssignment(ctx *Context) (cancel context.CancelFunc) {
return
}

tags, err := ctx.Repo.GitRepo.GetTags(0, 0)
tags, err := repo_model.GetTagNamesByRepoID(ctx, ctx.Repo.Repository.ID)
if err != nil {
if strings.Contains(err.Error(), "fatal: not a git repository ") {
log.Error("Repository %-v has a broken repository on the file system: %s Error: %v", ctx.Repo.Repository, ctx.Repo.Repository.RepoPath(), err)
ctx.Repo.Repository.Status = repo_model.RepositoryBroken
ctx.Repo.Repository.IsEmpty = true
ctx.Data["BranchName"] = ctx.Repo.Repository.DefaultBranch
// Only allow access to base of repo or settings
if !isHomeOrSettings {
ctx.Redirect(ctx.Repo.RepoLink)
}
return
}
ctx.ServerError("GetTags", err)
ctx.ServerError("GetTagNamesByRepoID", err)
return
}
ctx.Data["Tags"] = tags
Expand Down
4 changes: 4 additions & 0 deletions modules/git/log_name_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ func LogNameStatusRepo(ctx context.Context, repository, head, treepath string, p
} else if treepath != "" {
files = append(files, treepath)
}
// Use the :(literal) pathspec magic to handle edge cases with files named like ":file.txt" or "*.jpg"
for i, file := range files {
files[i] = ":(literal)" + file
}
cmd.AddDashesAndList(files...)

go func() {
Expand Down
3 changes: 3 additions & 0 deletions modules/templates/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ func NewFuncMap() []template.FuncMap {
"CustomEmojis": func() map[string]string {
return setting.UI.CustomEmojisMap
},
"IsShowFullName": func() bool {
return setting.UI.DefaultShowFullName
},
"Safe": Safe,
"SafeJS": SafeJS,
"JSEscape": JSEscape,
Expand Down
9 changes: 4 additions & 5 deletions routers/web/repo/compare.go
Original file line number Diff line number Diff line change
Expand Up @@ -717,10 +717,9 @@ func CompareDiff(ctx *context.Context) {
return
}

baseGitRepo := ctx.Repo.GitRepo
baseTags, err := baseGitRepo.GetTags(0, 0)
baseTags, err := repo_model.GetTagNamesByRepoID(ctx, ctx.Repo.Repository.ID)
if err != nil {
ctx.ServerError("GetTags", err)
ctx.ServerError("GetTagNamesByRepoID", err)
return
}
ctx.Data["Tags"] = baseTags
Expand All @@ -738,9 +737,9 @@ func CompareDiff(ctx *context.Context) {
}
ctx.Data["HeadBranches"] = headBranches

headTags, err := ci.HeadGitRepo.GetTags(0, 0)
headTags, err := repo_model.GetTagNamesByRepoID(ctx, ci.HeadRepo.ID)
if err != nil {
ctx.ServerError("GetTags", err)
ctx.ServerError("GetTagNamesByRepoID", err)
return
}
ctx.Data["HeadTags"] = headTags
Expand Down
4 changes: 2 additions & 2 deletions templates/repo/issue/list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
<a class="item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}">{{.locale.Tr "repo.issues.filter_poster_no_select"}}</a>
{{range .Posters}}
<a class="{{if eq $.PosterID .ID}}active selected{{end}} item" href="{{$.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{$.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{.ID}}">
{{avatar $.Context .}} {{.GetDisplayName}}
{{avatar $.Context .}}{{template "repo/search_name" .}}
</a>
{{end}}
</div>
Expand All @@ -154,7 +154,7 @@
<a class="item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&poster={{$.PosterID}}">{{.locale.Tr "repo.issues.filter_assginee_no_select"}}</a>
{{range .Assignees}}
<a class="{{if eq $.AssigneeID .ID}}active selected{{end}} item" href="{{$.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{$.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{.ID}}&poster={{$.PosterID}}">
{{avatar $.Context .}} {{.GetDisplayName}}
{{avatar $.Context .}}{{template "repo/search_name" .}}
</a>
{{end}}
</div>
Expand Down
9 changes: 6 additions & 3 deletions templates/repo/issue/milestone_issues.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,14 @@
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
</span>
<div class="menu">
<div class="ui icon search input">
<i class="icon gt-df gt-ac gt-jc">{{svg "octicon-search" 16}}</i>
<input type="text" placeholder="{{.locale.Tr "repo.issues.filter_poster"}}">
</div>
<a class="item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{.SelectLabels}}&assignee={{$.AssigneeID}}">{{.locale.Tr "repo.issues.filter_poster_no_select"}}</a>
{{range .Posters}}
<a class="{{if eq $.PosterID .ID}}active selected{{end}} item" href="{{$.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{$.SelectLabels}}&assignee={{$.AssigneeID}}&poster={{.ID}}">
{{avatar $.Context .}} {{.GetDisplayName}}
{{avatar $.Context .}}{{template "repo/search_name" .}}
</a>
{{end}}
</div>
Expand All @@ -93,8 +97,7 @@
<a class="item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{.SelectLabels}}&poster={{$.PosterID}}">{{.locale.Tr "repo.issues.filter_assginee_no_select"}}</a>
{{range .Assignees}}
<a class="{{if eq $.AssigneeID .ID}}active selected{{end}} item" href="{{$.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{$.SelectLabels}}&assignee={{.ID}}&poster={{$.PosterID}}">
{{avatar $.Context . 28 "gt-mr-2"}}
{{.GetDisplayName}}
{{avatar $.Context . 28 "gt-mr-2"}}{{template "repo/search_name" .}}
</a>
{{end}}
</div>
Expand Down
2 changes: 1 addition & 1 deletion templates/repo/issue/new_form.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
<a class="item muted" href="#" data-id="{{.ID}}" data-id-selector="#assignee_{{.ID}}">
<span class="octicon-check invisible">{{svg "octicon-check"}}</span>
<span class="text">
{{avatar $.Context . 28 "gt-mr-3"}}{{.GetDisplayName}}
{{avatar $.Context . 28 "gt-mr-3"}}{{template "repo/search_name" .}}
</span>
</a>
{{end}}
Expand Down
6 changes: 2 additions & 4 deletions templates/repo/issue/view_content/sidebar.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
<a class="{{if not .CanChange}}ui tooltip{{end}} item {{if .Checked}} checked {{end}} {{if not .CanChange}}ban-change{{end}}" href="#" data-id="{{.ItemID}}" data-id-selector="#review_request_{{.ItemID}}" {{if not .CanChange}} data-content="{{$.locale.Tr "repo.issues.remove_request_review_block"}}"{{end}}>
<span class="octicon-check {{if not .Checked}}invisible{{end}}">{{svg "octicon-check"}}</span>
<span class="text">
{{avatar $.Context .User 28 "gt-mr-3"}}
{{.User.GetDisplayName}}
{{avatar $.Context .User 28 "gt-mr-3"}}{{template "repo/search_name" .User}}
</span>
</a>
{{end}}
Expand Down Expand Up @@ -258,8 +257,7 @@
{{end}}
<span class="octicon-check {{if not $checked}}invisible{{end}}">{{svg "octicon-check"}}</span>
<span class="text">
{{avatar $.Context . 28 "gt-mr-3"}}
{{.GetDisplayName}}
{{avatar $.Context . 28 "gt-mr-3"}}{{template "repo/search_name" .}}
</span>
</a>
{{end}}
Expand Down
1 change: 1 addition & 0 deletions templates/repo/search_name.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{.Name}}{{if IsShowFullName}}<span class="search-fullname"> {{.FullName}}</span>{{end}}
9 changes: 3 additions & 6 deletions templates/repo/settings/protected_branch.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@
<div class="menu">
{{range .Users}}
<div class="item" data-value="{{.ID}}">
{{avatar $.Context . 28 "mini"}}
{{.GetDisplayName}}
{{avatar $.Context . 28 "mini"}}{{template "repo/search_name" .}}
</div>
{{end}}
</div>
Expand Down Expand Up @@ -101,8 +100,7 @@
<div class="menu">
{{range .Users}}
<div class="item" data-value="{{.ID}}">
{{avatar $.Context . 28 "mini"}}
{{.GetDisplayName}}
{{avatar $.Context . 28 "mini"}}{{template "repo/search_name" .}}
</div>
{{end}}
</div>
Expand Down Expand Up @@ -181,8 +179,7 @@
<div class="menu">
{{range .Users}}
<div class="item" data-value="{{.ID}}">
{{avatar $.Context . 28 "mini"}}
{{.GetDisplayName}}
{{avatar $.Context . 28 "mini"}}{{template "repo/search_name" .}}
</div>
{{end}}
</div>
Expand Down
3 changes: 1 addition & 2 deletions templates/repo/settings/tags.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@
<div class="menu">
{{range .Users}}
<div class="item" data-value="{{.ID}}">
{{avatar $.Context . 28 "mini"}}
{{.GetDisplayName}}
{{avatar $.Context . 28 "mini"}}{{template "repo/search_name" .}}
</div>
{{end}}
</div>
Expand Down
4 changes: 4 additions & 0 deletions web_src/css/repository.css
Original file line number Diff line number Diff line change
Expand Up @@ -3627,3 +3627,7 @@ td.blob-excerpt {
.pr-status .status-details > span {
padding-right: 0.5em; /* To match the alignment with the "required" label */
}

.search-fullname {
color: var(--color-text-light-2);
}

0 comments on commit e15d400

Please sign in to comment.