Skip to content

Commit 8eb24fd

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: Release and Tag List tweaks (go-gitea#21712) Fix issue/PR numbers (go-gitea#22037)
2 parents 8b86552 + e2fa84f commit 8eb24fd

File tree

8 files changed

+91
-50
lines changed

8 files changed

+91
-50
lines changed

models/issues/issue.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -997,12 +997,7 @@ func NewIssueWithIndex(ctx context.Context, doer *user_model.User, opts NewIssue
997997
}
998998
}
999999

1000-
if opts.IsPull {
1001-
_, err = e.Exec("UPDATE `repository` SET num_pulls = num_pulls + 1 WHERE id = ?", opts.Issue.RepoID)
1002-
} else {
1003-
_, err = e.Exec("UPDATE `repository` SET num_issues = num_issues + 1 WHERE id = ?", opts.Issue.RepoID)
1004-
}
1005-
if err != nil {
1000+
if err := repo_model.UpdateRepoIssueNumbers(ctx, opts.Issue.RepoID, opts.IsPull, false); err != nil {
10061001
return err
10071002
}
10081003

models/repo.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ func CheckRepoStats(ctx context.Context) error {
443443
},
444444
// Repository.NumIssues
445445
{
446-
statsQuery("SELECT repo.id FROM `repository` repo WHERE repo.num_issues!=(SELECT COUNT(*) FROM `issue` WHERE repo_id=repo.id AND is_closed=? AND is_pull=?)", false, false),
446+
statsQuery("SELECT repo.id FROM `repository` repo WHERE repo.num_issues!=(SELECT COUNT(*) FROM `issue` WHERE repo_id=repo.id AND is_pull=?)", false),
447447
repoStatsCorrectNumIssues,
448448
"repository count 'num_issues'",
449449
},
@@ -455,7 +455,7 @@ func CheckRepoStats(ctx context.Context) error {
455455
},
456456
// Repository.NumPulls
457457
{
458-
statsQuery("SELECT repo.id FROM `repository` repo WHERE repo.num_pulls!=(SELECT COUNT(*) FROM `issue` WHERE repo_id=repo.id AND is_closed=? AND is_pull=?)", false, true),
458+
statsQuery("SELECT repo.id FROM `repository` repo WHERE repo.num_pulls!=(SELECT COUNT(*) FROM `issue` WHERE repo_id=repo.id AND is_pull=?)", true),
459459
repoStatsCorrectNumPulls,
460460
"repository count 'num_pulls'",
461461
},

services/issue/issue.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,16 @@ func deleteIssue(issue *issues_model.Issue) error {
218218
return err
219219
}
220220

221-
if err := repo_model.UpdateRepoIssueNumbers(ctx, issue.RepoID, issue.IsPull, issue.IsClosed); err != nil {
221+
// update the total issue numbers
222+
if err := repo_model.UpdateRepoIssueNumbers(ctx, issue.RepoID, issue.IsPull, false); err != nil {
222223
return err
223224
}
225+
// if the issue is closed, update the closed issue numbers
226+
if issue.IsClosed {
227+
if err := repo_model.UpdateRepoIssueNumbers(ctx, issue.RepoID, issue.IsPull, true); err != nil {
228+
return err
229+
}
230+
}
224231

225232
if err := issues_model.UpdateMilestoneCounters(ctx, issue.MilestoneID); err != nil {
226233
return fmt.Errorf("error updating counters for milestone id %d: %w",

templates/repo/release/list.tmpl

Lines changed: 42 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,21 @@
3636
</h3>
3737
<div class="download df ac">
3838
{{if $.Permission.CanRead $.UnitTypeCode}}
39-
<a class="mr-3 mono" href="{{$.RepoLink}}/src/commit/{{.Sha1}}" rel="nofollow">{{svg "octicon-git-commit" 16 "mr-2"}}{{ShortSha .Sha1}}</a>
39+
<a class="mr-3 mono muted" href="{{$.RepoLink}}/src/commit/{{.Sha1}}" rel="nofollow">{{svg "octicon-git-commit" 16 "mr-2"}}{{ShortSha .Sha1}}</a>
4040
{{if not $.DisableDownloadSourceArchives}}
41-
<a class="archive-link mr-3" href="{{$.RepoLink}}/archive/{{.TagName | PathEscapeSegments}}.zip" rel="nofollow">{{svg "octicon-file-zip" 16 "mr-2"}}ZIP</a>
42-
<a class="archive-link mr-3" href="{{$.RepoLink}}/archive/{{.TagName | PathEscapeSegments}}.tar.gz" rel="nofollow">{{svg "octicon-file-zip" 16 "mr-2"}}TAR.GZ</a>
41+
<a class="archive-link mr-3 muted" href="{{$.RepoLink}}/archive/{{.TagName | PathEscapeSegments}}.zip" rel="nofollow">{{svg "octicon-file-zip" 16 "mr-2"}}ZIP</a>
42+
<a class="archive-link mr-3 muted" href="{{$.RepoLink}}/archive/{{.TagName | PathEscapeSegments}}.tar.gz" rel="nofollow">{{svg "octicon-file-zip" 16 "mr-2"}}TAR.GZ</a>
4343
{{end}}
4444
{{if (and $.CanCreateRelease $release.IsTag)}}
45-
<a class="mr-3" href="{{$.RepoLink}}/releases/new?tag={{.TagName}}">{{svg "octicon-tag" 16 "mr-2"}}{{$.locale.Tr "repo.release.new_release"}}</a>
45+
<a class="mr-3 muted" href="{{$.RepoLink}}/releases/new?tag={{.TagName}}">{{svg "octicon-tag" 16 "mr-2"}}{{$.locale.Tr "repo.release.new_release"}}</a>
4646
{{end}}
4747
{{if (and ($.Permission.CanWrite $.UnitTypeCode) $release.IsTag)}}
48-
<a class="ui red delete-button mr-3" data-url="{{$.RepoLink}}/tags/delete" data-id="{{.ID}}">
48+
<a class="ui delete-button mr-3 muted" data-url="{{$.RepoLink}}/tags/delete" data-id="{{.ID}}">
4949
{{svg "octicon-trash" 16 "mr-2"}}{{$.locale.Tr "repo.release.delete_tag"}}
5050
</a>
5151
{{end}}
5252
{{if (not $release.IsTag)}}
53-
<a class="mr-3" href="{{$.RepoLink}}/releases/tag/{{.TagName | PathEscapeSegments}}">{{svg "octicon-tag" 16 "mr-2"}}{{$.locale.Tr "repo.release.detail"}}</a>
53+
<a class="mr-3 muted" href="{{$.RepoLink}}/releases/tag/{{.TagName | PathEscapeSegments}}">{{svg "octicon-tag" 16 "mr-2"}}{{$.locale.Tr "repo.release.detail"}}</a>
5454
{{end}}
5555
{{end}}
5656
</div>
@@ -69,56 +69,67 @@
6969
{{if .IsTag}}
7070
{{if .CreatedUnix}}<span class="time">{{TimeSinceUnix .CreatedUnix $.locale}}</span>{{end}}
7171
{{else}}
72-
{{if .IsDraft}}
73-
<span class="ui yellow label">{{$.locale.Tr "repo.release.draft"}}</span>
74-
{{else if .IsPrerelease}}
75-
<span class="ui orange label">{{$.locale.Tr "repo.release.prerelease"}}</span>
76-
{{else}}
77-
<span class="ui green label">{{$.locale.Tr "repo.release.stable"}}</span>
78-
{{end}}
79-
<span class="tag text blue">
80-
<a class="df ac je" href="{{if not .Sha1}}#{{else}}{{$.RepoLink}}/src/tag/{{.TagName | PathEscapeSegments}}{{end}}" rel="nofollow">{{svg "octicon-tag" 16 "mr-2"}}{{.TagName}}</a>
81-
</span>
72+
<a class="df ac je muted" href="{{if not .Sha1}}#{{else}}{{$.RepoLink}}/src/tag/{{.TagName | PathEscapeSegments}}{{end}}" rel="nofollow">{{svg "octicon-tag" 16 "mr-2"}}{{.TagName}}</a>
8273
{{if .Sha1}}
8374
<span class="commit">
84-
<a class="mono" href="{{$.RepoLink}}/src/commit/{{.Sha1}}" rel="nofollow">{{svg "octicon-git-commit" 16 "mr-2"}}{{ShortSha .Sha1}}</a>
75+
<a class="mono muted" href="{{$.RepoLink}}/src/commit/{{.Sha1}}" rel="nofollow">{{svg "octicon-git-commit" 16 "mr-2"}}{{ShortSha .Sha1}}</a>
8576
</span>
8677
{{template "repo/branch_dropdown" dict "root" $ "release" .}}
8778
{{end}}
8879
{{end}}
8980
</div>
9081
<div class="ui twelve wide column detail">
9182
{{if .IsTag}}
92-
<h4>
93-
<a href="{{$.RepoLink}}/src/tag/{{.TagName | PathEscapeSegments}}" rel="nofollow">{{svg "octicon-tag" 16 "mr-2"}}{{.TagName}}</a>
94-
</h4>
83+
<div class="df ac sb fw mb-3">
84+
<h4 class="release-list-title df ac">
85+
<a class="df ac" href="{{$.RepoLink}}/src/tag/{{.TagName | PathEscapeSegments}}" rel="nofollow">{{svg "octicon-tag" 24 "mr-3"}}{{.TagName}}</a>
86+
</h4>
87+
</div>
9588
<p class="text grey">
9689
{{if gt .Publisher.ID 0}}
9790
<span class="author">
9891
{{avatar .Publisher 20}}
9992
<a href="{{.Publisher.HomeLink}}">{{.Publisher.Name}}</a>
10093
</span>
94+
<span class="released">
95+
{{$.locale.Tr "repo.released_this"}}
96+
</span>
97+
{{if .CreatedUnix}}
98+
<span class="time">{{TimeSinceUnix .CreatedUnix $.locale}}</span>
99+
{{end}}
100+
|
101101
{{end}}
102102
<span class="ahead"><a href="{{$.RepoLink}}/compare/{{.TagName | PathEscapeSegments}}{{if .Target}}...{{.Target | PathEscapeSegments}}{{end}}">{{$.locale.Tr "repo.release.ahead.commits" .NumCommitsBehind | Str2html}}</a> {{$.locale.Tr "repo.release.ahead.target" $.DefaultBranch}}</span>
103103
</p>
104104
<div class="download">
105105
{{if $.Permission.CanRead $.UnitTypeCode}}
106-
<a class="mono" href="{{$.RepoLink}}/src/commit/{{.Sha1}}" rel="nofollow">{{svg "octicon-git-commit" 16 "mr-2"}}{{ShortSha .Sha1}}</a>
106+
<a class="mono muted" href="{{$.RepoLink}}/src/commit/{{.Sha1}}" rel="nofollow">{{svg "octicon-git-commit" 16 "mr-2"}}{{ShortSha .Sha1}}</a>
107107
{{if not $.DisableDownloadSourceArchives}}
108-
<a class="archive-link" href="{{$.RepoLink}}/archive/{{.TagName | PathEscapeSegments}}.zip" rel="nofollow">{{svg "octicon-file-zip"}}&nbsp;ZIP</a>
109-
<a class="archive-link" href="{{$.RepoLink}}/archive/{{.TagName | PathEscapeSegments}}.tar.gz" rel="nofollow">{{svg "octicon-file-zip"}}&nbsp;TAR.GZ</a>
108+
<a class="archive-link muted" href="{{$.RepoLink}}/archive/{{.TagName | PathEscapeSegments}}.zip" rel="nofollow">{{svg "octicon-file-zip"}}&nbsp;ZIP</a>
109+
<a class="archive-link muted" href="{{$.RepoLink}}/archive/{{.TagName | PathEscapeSegments}}.tar.gz" rel="nofollow">{{svg "octicon-file-zip"}}&nbsp;TAR.GZ</a>
110110
{{end}}
111111
{{end}}
112112
</div>
113113
{{else}}
114-
<h4 class="release-list-title df ac">
115-
<a href="{{$.RepoLink}}/releases/tag/{{.TagName | PathEscapeSegments}}">{{.Title}}</a>
116-
{{if $.CanCreateRelease}}
117-
<small class="ml-2">
118-
(<a href="{{$.RepoLink}}/releases/edit/{{.TagName | PathEscapeSegments}}" rel="nofollow">{{$.locale.Tr "repo.release.edit"}}</a>)
119-
</small>
120-
{{end}}
121-
</h4>
114+
<div class="df ac sb fw mb-3">
115+
<h4 class="release-list-title df ac">
116+
<a href="{{$.RepoLink}}/releases/tag/{{.TagName | PathEscapeSegments}}">{{.Title}}</a>
117+
{{if .IsDraft}}
118+
<span class="ui yellow label ml-3 mt-1">{{$.locale.Tr "repo.release.draft"}}</span>
119+
{{else if .IsPrerelease}}
120+
<span class="ui orange label ml-3 mt-1">{{$.locale.Tr "repo.release.prerelease"}}</span>
121+
{{else if not .IsTag}}
122+
<span class="ui green label ml-3 mt-1">{{$.locale.Tr "repo.release.stable"}}</span>
123+
{{end}}
124+
</h4>
125+
<div class="df ac">
126+
{{if $.CanCreateRelease}}
127+
<a class="muted tooltip ml-3 df ac" data-content="{{$.locale.Tr "repo.release.edit"}}" href="{{$.RepoLink}}/releases/edit/{{.TagName | PathEscapeSegments}}" rel="nofollow">
128+
{{svg "octicon-pencil"}}
129+
</a>
130+
{{end}}
131+
</div>
132+
</div>
122133
<p class="text grey">
123134
<span class="author">
124135
{{if .OriginalAuthor}}

tests/integration/release_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func checkLatestReleaseAndCount(t *testing.T, session *TestSession, repoURL, ver
5353
resp := session.MakeRequest(t, req, http.StatusOK)
5454

5555
htmlDoc := NewHTMLParser(t, resp.Body)
56-
labelText := htmlDoc.doc.Find("#release-list > li .meta .label").First().Text()
56+
labelText := htmlDoc.doc.Find("#release-list > li .detail .label").First().Text()
5757
assert.EqualValues(t, label, labelText)
5858
titleText := htmlDoc.doc.Find("#release-list > li .detail h4 a").First().Text()
5959
assert.EqualValues(t, version, titleText)

web_src/less/_base.less

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@
108108
--color-diff-inactive: #f2f2f2;
109109
--color-error-border: #e0b4b4;
110110
--color-error-bg: #fff6f6;
111+
--color-error-bg-active: #fbb;
112+
--color-error-bg-hover: #fdd;
111113
--color-error-text: #9f3a38;
112114
--color-success-border: #a3c293;
113115
--color-success-bg: #fcfff5;
@@ -1293,6 +1295,11 @@ a.ui.card:hover,
12931295
.ui.form .fields.error .field input[type="text"],
12941296
.ui.form .fields.error .field input[type="file"],
12951297
.ui.form .fields.error .field input[type="url"],
1298+
.ui.form .fields.error .field .ui.dropdown,
1299+
.ui.form .fields.error .field .ui.dropdown .item,
1300+
.ui.form .field.error .ui.dropdown,
1301+
.ui.form .field.error .ui.dropdown .text,
1302+
.ui.form .field.error .ui.dropdown .item,
12961303
.ui.form .field.error textarea,
12971304
.ui.form .field.error select,
12981305
.ui.form .field.error input:not([type]),
@@ -1321,10 +1328,32 @@ a.ui.card:hover,
13211328
.ui.form .field.error input[type="file"]:focus,
13221329
.ui.form .field.error input[type="url"]:focus {
13231330
background-color: var(--color-error-bg);
1324-
border: 1px solid var(--color-error-border);
1331+
border-color: var(--color-error-border);
13251332
color: var(--color-error-text);
13261333
}
13271334

1335+
.ui.form .fields.error .field .ui.dropdown,
1336+
.ui.form .field.error .ui.dropdown,
1337+
.ui.form .fields.error .field .ui.dropdown:hover,
1338+
.ui.form .field.error .ui.dropdown:hover {
1339+
border-color: var(--color-error-border) !important;
1340+
}
1341+
1342+
.ui.form .fields.error .field .ui.dropdown .menu .item:hover,
1343+
.ui.form .field.error .ui.dropdown .menu .item:hover {
1344+
background-color: var(--color-error-bg-hover);
1345+
}
1346+
1347+
.ui.form .fields.error .field .ui.dropdown .menu .active.item,
1348+
.ui.form .field.error .ui.dropdown .menu .active.item {
1349+
background-color: var(--color-error-bg-active) !important;
1350+
}
1351+
1352+
.ui.form .fields.error .dropdown .menu,
1353+
.ui.form .field.error .dropdown .menu {
1354+
border-color: var(--color-error-border) !important;
1355+
}
1356+
13281357
.ui.loading.loading.input > i.icon svg {
13291358
visibility: hidden;
13301359
}

web_src/less/_repository.less

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1855,11 +1855,13 @@
18551855
border-top: 1px solid var(--color-secondary);
18561856
margin-top: 20px;
18571857
padding-top: 15px;
1858+
padding-left: 0;
18581859

18591860
.release-list-title {
18601861
font-size: 2rem;
18611862
font-weight: normal;
1862-
margin-top: -6px;
1863+
margin-top: -4px;
1864+
margin-bottom: 0;
18631865
}
18641866

18651867
> li {
@@ -1879,11 +1881,6 @@
18791881
margin-right: 0;
18801882
}
18811883

1882-
.tag:not(.icon) {
1883-
display: block;
1884-
margin-top: 15px;
1885-
}
1886-
18871884
.commit {
18881885
display: block;
18891886
margin-top: 10px;
@@ -1903,7 +1900,7 @@
19031900

19041901
.author {
19051902
img {
1906-
margin-bottom: -3px;
1903+
margin-bottom: 3px;
19071904
}
19081905
}
19091906

@@ -1966,7 +1963,7 @@
19661963
}
19671964

19681965
.release-tag-name {
1969-
font-size: 20px;
1966+
font-size: 18px;
19701967
font-weight: normal;
19711968
}
19721969
}

web_src/less/themes/theme-arc-green.less

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@
9797
--color-diff-inactive: #353846;
9898
--color-error-border: #a04141;
9999
--color-error-bg: #522;
100+
--color-error-bg-active: #744;
101+
--color-error-bg-hover: #633;
100102
--color-error-text: #f9cbcb;
101103
--color-success-border: #458a57;
102104
--color-success-bg: #284034;

0 commit comments

Comments
 (0)