Skip to content

Commit 098f110

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: Wrap contained tags and branches again (go-gitea#29021) Avoid sending update/delete release notice when it is draft (go-gitea#29008) Fix incorrect button CSS usages (go-gitea#29015) Strip trailing newline in markdown code copy (go-gitea#29019) Improve user search display name (go-gitea#29002)
2 parents 372bce6 + 71422c0 commit 098f110

File tree

14 files changed

+34
-44
lines changed

14 files changed

+34
-44
lines changed

routers/utils/utils.go

-8
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,6 @@ import (
1111
"code.gitea.io/gitea/modules/setting"
1212
)
1313

14-
// RemoveUsernameParameterSuffix returns the username parameter without the (fullname) suffix - leaving just the username
15-
func RemoveUsernameParameterSuffix(name string) string {
16-
if index := strings.Index(name, " ("); index >= 0 {
17-
name = name[:index]
18-
}
19-
return name
20-
}
21-
2214
// SanitizeFlashErrorString will sanitize a flash error string
2315
func SanitizeFlashErrorString(x string) string {
2416
return strings.ReplaceAll(html.EscapeString(x), "\n", "<br>")

routers/utils/utils_test.go

-6
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@ import (
1111
"github.com/stretchr/testify/assert"
1212
)
1313

14-
func TestRemoveUsernameParameterSuffix(t *testing.T) {
15-
assert.Equal(t, "foobar", RemoveUsernameParameterSuffix("foobar (Foo Bar)"))
16-
assert.Equal(t, "foobar", RemoveUsernameParameterSuffix("foobar"))
17-
assert.Equal(t, "", RemoveUsernameParameterSuffix(""))
18-
}
19-
2014
func TestIsExternalURL(t *testing.T) {
2115
setting.AppURL = "https://try.gitea.io/"
2216
type test struct {

routers/web/org/teams.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424
"code.gitea.io/gitea/modules/log"
2525
"code.gitea.io/gitea/modules/setting"
2626
"code.gitea.io/gitea/modules/web"
27-
"code.gitea.io/gitea/routers/utils"
2827
shared_user "code.gitea.io/gitea/routers/web/shared/user"
2928
"code.gitea.io/gitea/services/convert"
3029
"code.gitea.io/gitea/services/forms"
@@ -127,7 +126,7 @@ func TeamsAction(ctx *context.Context) {
127126
ctx.Error(http.StatusNotFound)
128127
return
129128
}
130-
uname := utils.RemoveUsernameParameterSuffix(strings.ToLower(ctx.FormString("uname")))
129+
uname := strings.ToLower(ctx.FormString("uname"))
131130
var u *user_model.User
132131
u, err = user_model.GetUserByName(ctx, uname)
133132
if err != nil {

routers/web/repo/setting/collaboration.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
"code.gitea.io/gitea/modules/log"
1818
repo_module "code.gitea.io/gitea/modules/repository"
1919
"code.gitea.io/gitea/modules/setting"
20-
"code.gitea.io/gitea/routers/utils"
2120
"code.gitea.io/gitea/services/mailer"
2221
org_service "code.gitea.io/gitea/services/org"
2322
repo_service "code.gitea.io/gitea/services/repository"
@@ -52,7 +51,7 @@ func Collaboration(ctx *context.Context) {
5251

5352
// CollaborationPost response for actions for a collaboration of a repository
5453
func CollaborationPost(ctx *context.Context) {
55-
name := utils.RemoveUsernameParameterSuffix(strings.ToLower(ctx.FormString("collaborator")))
54+
name := strings.ToLower(ctx.FormString("collaborator"))
5655
if len(name) == 0 || ctx.Repo.Owner.LowerName == name {
5756
ctx.Redirect(setting.AppSubURL + ctx.Req.URL.EscapedPath())
5857
return
@@ -144,7 +143,7 @@ func AddTeamPost(ctx *context.Context) {
144143
return
145144
}
146145

147-
name := utils.RemoveUsernameParameterSuffix(strings.ToLower(ctx.FormString("team")))
146+
name := strings.ToLower(ctx.FormString("team"))
148147
if len(name) == 0 {
149148
ctx.Redirect(ctx.Repo.RepoLink + "/settings/collaboration")
150149
return

services/release/release.go

+7-8
Original file line numberDiff line numberDiff line change
@@ -291,15 +291,13 @@ func UpdateRelease(ctx context.Context, doer *user_model.User, gitRepo *git.Repo
291291
}
292292
}
293293

294-
if !isCreated {
295-
notify_service.UpdateRelease(gitRepo.Ctx, doer, rel)
296-
return nil
297-
}
298-
299294
if !rel.IsDraft {
295+
if !isCreated {
296+
notify_service.UpdateRelease(gitRepo.Ctx, doer, rel)
297+
return nil
298+
}
300299
notify_service.NewRelease(gitRepo.Ctx, rel)
301300
}
302-
303301
return nil
304302
}
305303

@@ -368,8 +366,9 @@ func DeleteReleaseByID(ctx context.Context, repo *repo_model.Repository, rel *re
368366
}
369367
}
370368

371-
notify_service.DeleteRelease(ctx, doer, rel)
372-
369+
if !rel.IsDraft {
370+
notify_service.DeleteRelease(ctx, doer, rel)
371+
}
373372
return nil
374373
}
375374

templates/repo/commit_load_branches_and_tags.tmpl

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
<div>{{ctx.Locale.Tr "repo.commit.contained_in"}}</div>
1010
<div class="gt-df gt-mt-3">
1111
<div class="gt-p-2">{{svg "octicon-git-branch"}}</div>
12-
<div class="branch-area flex-text-block gt-f1"></div>
12+
<div class="branch-area flex-text-block gt-fw gt-f1"></div>
1313
</div>
1414
<div class="gt-df gt-mt-3">
1515
<div class="gt-p-2">{{svg "octicon-tag"}}</div>
16-
<div class="tag-area flex-text-block gt-f1"></div>
16+
<div class="tag-area flex-text-block gt-fw gt-f1"></div>
1717
</div>
1818
</div>
1919
</div>

templates/repo/settings/lfs_file.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
{{else if .IsPDFFile}}
3434
<div class="pdf-content is-loading" data-src="{{$.RawFileLink}}" data-fallback-button-text="{{ctx.Locale.Tr "diff.view_file"}}"></div>
3535
{{else}}
36-
<a href="{{$.RawFileLink}}" rel="nofollow" class="btn btn-gray btn-radius">{{ctx.Locale.Tr "repo.file_view_raw"}}</a>
36+
<a href="{{$.RawFileLink}}" rel="nofollow">{{ctx.Locale.Tr "repo.file_view_raw"}}</a>
3737
{{end}}
3838
</div>
3939
{{else if .FileSize}}

templates/repo/unicode_escape_prompt.tmpl

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{{if .EscapeStatus}}
22
{{if .EscapeStatus.HasInvisible}}
33
<div class="ui warning message unicode-escape-prompt gt-text-left">
4-
<button class="close icon hide-panel button" data-panel-closest=".message">{{svg "octicon-x" 16 "close inside"}}</button>
4+
<button class="btn close icon hide-panel" data-panel-closest=".message">{{svg "octicon-x" 16 "close inside"}}</button>
55
<div class="header">
66
{{ctx.Locale.Tr "repo.invisible_runes_header"}}
77
</div>
@@ -12,7 +12,7 @@
1212
</div>
1313
{{else if .EscapeStatus.HasAmbiguous}}
1414
<div class="ui warning message unicode-escape-prompt gt-text-left">
15-
<button class="close icon hide-panel button" data-panel-closest=".message">{{svg "octicon-x" 16 "close inside"}}</button>
15+
<button class="btn close icon hide-panel" data-panel-closest=".message">{{svg "octicon-x" 16 "close inside"}}</button>
1616
<div class="header">
1717
{{ctx.Locale.Tr "repo.ambiguous_runes_header"}}
1818
</div>

templates/repo/view_file.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
{{else if .IsPDFFile}}
109109
<div class="pdf-content is-loading" data-src="{{$.RawFileLink}}" data-fallback-button-text="{{ctx.Locale.Tr "repo.diff.view_file"}}"></div>
110110
{{else}}
111-
<a href="{{$.RawFileLink}}" rel="nofollow" class="btn btn-gray btn-radius">{{ctx.Locale.Tr "repo.file_view_raw"}}</a>
111+
<a href="{{$.RawFileLink}}" rel="nofollow">{{ctx.Locale.Tr "repo.file_view_raw"}}</a>
112112
{{end}}
113113
</div>
114114
{{else if .FileSize}}

web_src/css/base.css

+4
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,14 @@ a.label,
196196
.ui.search > .results {
197197
background: var(--color-body);
198198
border-color: var(--color-secondary);
199+
overflow-wrap: anywhere; /* allow text to wrap as fomantic limits this to 18em width */
199200
}
200201

201202
.ui.search > .results .result {
202203
background: var(--color-body);
204+
border-color: var(--color-secondary);
205+
display: flex;
206+
align-items: center;
203207
}
204208

205209
.ui.search > .results .result .title {

web_src/css/repo.css

+5-3
Original file line numberDiff line numberDiff line change
@@ -2128,14 +2128,16 @@
21282128
}
21292129

21302130
#search-user-box .results .result .image {
2131-
float: left;
2132-
margin-right: 8px;
2131+
order: 0;
2132+
margin-right: 12px;
21332133
width: 2em;
21342134
height: 2em;
2135+
min-width: 2em;
2136+
min-height: 2em;
21352137
}
21362138

21372139
#search-user-box .results .result .content {
2138-
margin: 6px 0; /* this trick is used to align with the sibling avatar image */
2140+
margin: 0; /* remove margin reserved for avatar because we move it to left via `order: 0` */
21392141
}
21402142

21412143
.ui.menu .item > img:not(.ui) {

web_src/js/features/comp/SearchUserBox.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,13 @@ export function initCompSearchUserBox() {
1717
const searchQuery = $searchUserBox.find('input').val();
1818
const searchQueryUppercase = searchQuery.toUpperCase();
1919
$.each(response.data, (_i, item) => {
20-
let title = item.login;
21-
if (item.full_name && item.full_name.length > 0) {
22-
title += ` (${htmlEscape(item.full_name)})`;
23-
}
2420
const resultItem = {
25-
title,
21+
title: item.login,
2622
image: item.avatar_url
2723
};
24+
if (item.full_name) {
25+
resultItem.description = htmlEscape(item.full_name);
26+
}
2827
if (searchQueryUppercase === item.login.toUpperCase()) {
2928
items.unshift(resultItem);
3029
} else {

web_src/js/features/repo-settings.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ export function initRepoSettingSearchTeamBox() {
5252
onResponse(response) {
5353
const items = [];
5454
$.each(response.data, (_i, item) => {
55-
const title = `${item.name} (${item.permission} access)`;
5655
items.push({
57-
title,
56+
title: item.name,
57+
description: `${item.permission} access` // TODO: translate this string
5858
});
5959
});
6060

web_src/js/markup/codecopy.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ export function renderCodeCopy() {
1212
if (!els.length) return;
1313

1414
for (const el of els) {
15+
if (!el.textContent) continue;
1516
const btn = makeCodeCopyButton();
16-
btn.setAttribute('data-clipboard-text', el.textContent);
17+
// remove final trailing newline introduced during HTML rendering
18+
btn.setAttribute('data-clipboard-text', el.textContent.replace(/\r?\n$/, ''));
1719
el.after(btn);
1820
}
1921
}

0 commit comments

Comments
 (0)