Skip to content

Commit 74c2d26

Browse files
Merge branch 'master' into open-repository-open-cat-file-batch
2 parents 64c3ea8 + 5e047b9 commit 74c2d26

File tree

10 files changed

+84
-42
lines changed

10 files changed

+84
-42
lines changed

modules/nosql/manager_redis.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ func (m *Manager) GetRedisClient(connection string) redis.UniversalClient {
152152
opts.Addrs = append(opts.Addrs, strings.Split(uri.Host, ",")...)
153153
}
154154
if uri.Path != "" {
155-
if db, err := strconv.Atoi(uri.Path); err == nil {
155+
if db, err := strconv.Atoi(uri.Path[1:]); err == nil {
156156
opts.DB = db
157157
}
158158
}
@@ -168,7 +168,7 @@ func (m *Manager) GetRedisClient(connection string) redis.UniversalClient {
168168
opts.Addrs = append(opts.Addrs, strings.Split(uri.Host, ",")...)
169169
}
170170
if uri.Path != "" {
171-
if db, err := strconv.Atoi(uri.Path); err == nil {
171+
if db, err := strconv.Atoi(uri.Path[1:]); err == nil {
172172
opts.DB = db
173173
}
174174
}
@@ -186,7 +186,7 @@ func (m *Manager) GetRedisClient(connection string) redis.UniversalClient {
186186
opts.Addrs = append(opts.Addrs, strings.Split(uri.Host, ",")...)
187187
}
188188
if uri.Path != "" {
189-
if db, err := strconv.Atoi(uri.Path); err == nil {
189+
if db, err := strconv.Atoi(uri.Path[1:]); err == nil {
190190
opts.DB = db
191191
}
192192
}

modules/queue/queue_channel_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ func TestChannelQueue_Batch(t *testing.T) {
6868
WorkerPoolConfiguration: WorkerPoolConfiguration{
6969
QueueLength: 20,
7070
BatchLength: 2,
71-
BlockTimeout: 1 * time.Second,
72-
BoostTimeout: 5 * time.Minute,
73-
BoostWorkers: 5,
71+
BlockTimeout: 0,
72+
BoostTimeout: 0,
73+
BoostWorkers: 0,
7474
MaxWorkers: 10,
7575
},
7676
Workers: 1,

options/locale/locale_en-US.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,7 @@ branch = Branch
855855
tree = Tree
856856
clear_ref = `Clear current reference`
857857
filter_branch_and_tag = Filter branch or tag
858+
find_tag = Find tag
858859
branches = Branches
859860
tags = Tags
860861
issues = Issues
@@ -1913,6 +1914,7 @@ release.new_release = New Release
19131914
release.draft = Draft
19141915
release.prerelease = Pre-Release
19151916
release.stable = Stable
1917+
release.compare = Compare
19161918
release.edit = edit
19171919
release.ahead.commits = <strong>%d</strong> commits
19181920
release.ahead.target = to %s since this release

routers/repo/release.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ func TagsList(ctx *context.Context) {
7070
func releasesOrTags(ctx *context.Context, isTagList bool) {
7171
ctx.Data["PageIsReleaseList"] = true
7272
ctx.Data["DefaultBranch"] = ctx.Repo.Repository.DefaultBranch
73+
ctx.Data["IsViewBranch"] = false
74+
ctx.Data["IsViewTag"] = true
75+
// Disable the showCreateNewBranch form in the dropdown on this page.
76+
ctx.Data["CanCreateBranch"] = false
77+
ctx.Data["HideBranchesInDropdown"] = true
7378

7479
if isTagList {
7580
ctx.Data["Title"] = ctx.Tr("repo.release.tags")
@@ -79,6 +84,13 @@ func releasesOrTags(ctx *context.Context, isTagList bool) {
7984
ctx.Data["PageIsTagList"] = false
8085
}
8186

87+
tags, err := ctx.Repo.GitRepo.GetTags()
88+
if err != nil {
89+
ctx.ServerError("GetTags", err)
90+
return
91+
}
92+
ctx.Data["Tags"] = tags
93+
8294
writeAccess := ctx.Repo.CanWrite(models.UnitTypeReleases)
8395
ctx.Data["CanCreateRelease"] = writeAccess && !ctx.Repo.Repository.IsArchived
8496

templates/repo/branch_dropdown.tmpl

Lines changed: 46 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,78 @@
1-
<div class="fitted item choose reference mr-1">
2-
<div class="ui floating filter dropdown custom" data-can-create-branch="{{.CanCreateBranch}}" data-no-results="{{.i18n.Tr "repo.pulls.no_results"}}">
1+
{{$release := .release}}
2+
{{$showBranchesInDropdown := not .root.HideBranchesInDropdown}}
3+
<div class="fitted item choose reference{{if not $release}} mr-1{{end}}">
4+
<div class="ui floating filter dropdown custom" data-can-create-branch="{{.root.CanCreateBranch}}" data-no-results="{{.root.i18n.Tr "repo.pulls.no_results"}}">
35
<div class="ui basic small compact button" @click="menuVisible = !menuVisible" @keyup.enter="menuVisible = !menuVisible">
46
<span class="text">
5-
{{svg "octicon-git-branch"}}
6-
{{if .IsViewBranch}}{{.i18n.Tr "repo.branch"}}{{else}}{{.i18n.Tr "repo.tree"}}{{end}}:
7-
<strong>{{if .IsViewBranch}}{{.BranchName}}{{else}}{{ShortSha .BranchName}}{{end}}</strong>
7+
{{if $release}}
8+
{{.root.i18n.Tr "repo.release.compare"}}
9+
{{else}}
10+
{{svg "octicon-git-branch"}}
11+
{{if .root.IsViewBranch}}{{.root.i18n.Tr "repo.branch"}}{{else}}{{.root.i18n.Tr "repo.tree"}}{{end}}:
12+
<strong>{{if .root.IsViewBranch}}{{.root.BranchName}}{{else}}{{ShortSha .root.BranchName}}{{end}}</strong>
13+
{{end}}
814
</span>
915
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
1016
</div>
11-
<div class="data" style="display: none" data-mode="{{if .IsViewTag}}tags{{else}}branches{{end}}">
12-
{{range .Branches}}
13-
<div class="item branch {{if eq $.BranchName .}}selected{{end}}" data-url="{{$.RepoLink}}/{{if $.PageIsCommits}}commits{{else}}src{{end}}/branch/{{EscapePound .}}{{if $.TreePath}}/{{EscapePound $.TreePath}}{{end}}">{{.}}</div>
17+
<div class="data" style="display: none" data-mode="{{if .root.IsViewTag}}tags{{else}}branches{{end}}">
18+
{{if $showBranchesInDropdown}}
19+
{{range .root.Branches}}
20+
<div class="item branch {{if eq $.root.BranchName .}}selected{{end}}" data-url="{{$.root.RepoLink}}/{{if $.root.PageIsCommits}}commits{{else}}src{{end}}/branch/{{EscapePound .}}{{if $.root.TreePath}}/{{EscapePound $.root.TreePath}}{{end}}">{{.}}</div>
21+
{{end}}
1422
{{end}}
15-
{{range .Tags}}
16-
<div class="item tag {{if eq $.BranchName .}}selected{{end}}" data-url="{{$.RepoLink}}/{{if $.PageIsCommits}}commits{{else}}src{{end}}/tag/{{EscapePound .}}{{if $.TreePath}}/{{EscapePound $.TreePath}}{{end}}">{{.}}</div>
23+
{{range .root.Tags}}
24+
{{if $release}}
25+
<div class="item tag {{if eq $release.TagName .}}selected{{end}}" data-url="{{$.root.RepoLink}}/compare/{{EscapePound .}}...{{if $release.TagName}}{{EscapePound $release.TagName}}{{else}}{{EscapePound $release.Sha1}}{{end}}">{{.}}</div>
26+
{{else}}
27+
<div class="item tag {{if eq $.root.BranchName .}}selected{{end}}" data-url="{{$.root.RepoLink}}/{{if $.root.PageIsCommits}}commits{{else}}src{{end}}/tag/{{EscapePound .}}{{if $.root.TreePath}}/{{EscapePound $.root.TreePath}}{{end}}">{{.}}</div>
28+
{{end}}
1729
{{end}}
1830
</div>
1931
<div class="menu transition" :class="{visible: menuVisible}" v-if="menuVisible" v-cloak>
2032
<div class="ui icon search input">
2133
<i class="icon df ac jc m-0">{{svg "octicon-filter" 16}}</i>
22-
<input name="search" ref="searchField" v-model="searchTerm" @keydown="keydown($event)" placeholder="{{.i18n.Tr "repo.filter_branch_and_tag"}}...">
34+
<input name="search" ref="searchField" v-model="searchTerm" @keydown="keydown($event)" placeholder="{{if $showBranchesInDropdown}}{{.root.i18n.Tr "repo.filter_branch_and_tag"}}{{else}}{{.root.i18n.Tr "repo.find_tag"}}{{end}}...">
2335
</div>
24-
<div class="header branch-tag-choice">
25-
<div class="ui grid">
26-
<div class="two column row">
27-
<a class="reference column" href="#" @click="createTag = false; mode = 'branches'; focusSearchField()">
28-
<span class="text" :class="{black: mode == 'branches'}">
29-
{{svg "octicon-git-branch" 16 "mr-2"}}{{.i18n.Tr "repo.branches"}}
30-
</span>
31-
</a>
32-
<a class="reference column" href="#" @click="createTag = true; mode = 'tags'; focusSearchField()">
33-
<span class="text" :class="{black: mode == 'tags'}">
34-
{{svg "octicon-tag" 16 "mr-2"}}{{.i18n.Tr "repo.tags"}}
35-
</span>
36-
</a>
36+
{{if $showBranchesInDropdown}}
37+
<div class="header branch-tag-choice">
38+
<div class="ui grid">
39+
<div class="two column row">
40+
<a class="reference column" href="#" @click="createTag = false; mode = 'branches'; focusSearchField()">
41+
<span class="text" :class="{black: mode == 'branches'}">
42+
{{svg "octicon-git-branch" 16 "mr-2"}}{{.root.i18n.Tr "repo.branches"}}
43+
</span>
44+
</a>
45+
<a class="reference column" href="#" @click="createTag = true; mode = 'tags'; focusSearchField()">
46+
<span class="text" :class="{black: mode == 'tags'}">
47+
{{svg "octicon-tag" 16 "mr-2"}}{{.root.i18n.Tr "repo.tags"}}
48+
</span>
49+
</a>
50+
</div>
3751
</div>
3852
</div>
39-
</div>
53+
{{end}}
4054
<div class="scrolling menu" ref="scrollContainer">
4155
<div v-for="(item, index) in filteredItems" :key="item.name" class="item" :class="{selected: item.selected, active: active == index}" @click="selectItem(item)" :ref="'listItem' + index">${ item.name }</div>
4256
<div class="item" v-if="showCreateNewBranch" :class="{active: active == filteredItems.length}" :ref="'listItem' + filteredItems.length">
4357
<a href="#" @click="createNewBranch()">
4458
<div v-show="createTag">
4559
<i class="reference tags icon"></i>
46-
{{.i18n.Tr "repo.tag.create_tag" `${ searchTerm }` | Safe}}
60+
{{.root.i18n.Tr "repo.tag.create_tag" `${ searchTerm }` | Safe}}
4761
</div>
4862
<div v-show="!createTag">
4963
{{svg "octicon-git-branch"}}
50-
{{.i18n.Tr "repo.branch.create_branch" `${ searchTerm }` | Safe}}
64+
{{.root.i18n.Tr "repo.branch.create_branch" `${ searchTerm }` | Safe}}
5165
</div>
5266
<div class="text small">
53-
{{if .IsViewBranch}}
54-
{{.i18n.Tr "repo.branch.create_from" .BranchName}}
67+
{{if or .root.IsViewBranch $release}}
68+
{{.root.i18n.Tr "repo.branch.create_from" .root.BranchName}}
5569
{{else}}
56-
{{.i18n.Tr "repo.branch.create_from" (ShortSha .BranchName)}}
70+
{{.root.i18n.Tr "repo.branch.create_from" (ShortSha .root.BranchName)}}
5771
{{end}}
5872
</div>
5973
</a>
60-
<form ref="newBranchForm" action="{{.RepoLink}}/branches/_new/{{EscapePound .BranchNameSubURL}}" method="post">
61-
{{.CsrfTokenHtml}}
74+
<form ref="newBranchForm" action="{{.root.RepoLink}}/branches/_new/{{EscapePound .root.BranchNameSubURL}}" method="post">
75+
{{.root.CsrfTokenHtml}}
6276
<input type="hidden" name="new_branch_name" v-model="searchTerm">
6377
<input type="hidden" name="create_tag" v-model="createTag">
6478
</form>

templates/repo/commits.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<div class="ui container">
55
{{template "repo/sub_menu" .}}
66
<div class="ui secondary stackable menu mobile--margin-between-items">
7-
{{template "repo/branch_dropdown" .}}
7+
{{template "repo/branch_dropdown" dict "root" .}}
88
<div class="fitted item">
99
<a href="{{.RepoLink}}/graph" class="ui basic small compact button">
1010
<span class="text">

templates/repo/home.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
{{end}}
5858
{{template "repo/sub_menu" .}}
5959
<div class="ui stackable secondary menu mobile--margin-between-items mobile--no-negative-margins">
60-
{{template "repo/branch_dropdown" .}}
60+
{{template "repo/branch_dropdown" dict "root" .}}
6161
{{ $n := len .TreeNames}}
6262
{{ $l := Subtract $n 1}}
6363
<!-- If home page, show new PR. If not, show breadcrumb -->

templates/repo/release/list.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
<span class="commit">
8181
<a class="mono" href="{{$.RepoLink}}/src/commit/{{.Sha1}}" rel="nofollow">{{svg "octicon-git-commit" 16 "mr-2"}}{{ShortSha .Sha1}}</a>
8282
</span>
83+
{{template "repo/branch_dropdown" dict "root" $ "release" .}}
8384
{{end}}
8485
</div>
8586
<div class="ui twelve wide column detail">

web_src/js/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,8 @@ async function initRepository() {
781781
});
782782

783783
// File list and commits
784-
if ($('.repository.file.list').length > 0 || ('.repository.commits').length > 0) {
784+
if ($('.repository.file.list').length > 0 ||
785+
$('.repository.commits').length > 0 || $('.repository.release').length > 0) {
785786
initFilterBranchTagDropdown('.choose.reference .dropdown');
786787
}
787788

web_src/less/_repository.less

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1803,6 +1803,10 @@
18031803
text-align: right;
18041804
position: relative;
18051805

1806+
.label {
1807+
margin-right: 0;
1808+
}
1809+
18061810
.tag:not(.icon) {
18071811
display: block;
18081812
margin-top: 15px;
@@ -1812,6 +1816,14 @@
18121816
display: block;
18131817
margin-top: 10px;
18141818
}
1819+
1820+
.choose {
1821+
margin-top: 15px;
1822+
1823+
.button {
1824+
margin-right: 0;
1825+
}
1826+
}
18151827
}
18161828

18171829
.detail {
@@ -1855,7 +1867,7 @@
18551867
width: 9px;
18561868
height: 9px;
18571869
background-color: #ddd;
1858-
z-index: 999;
1870+
z-index: 9;
18591871
position: absolute;
18601872
display: block;
18611873
left: -5px;

0 commit comments

Comments
 (0)