Skip to content

Commit

Permalink
Merge remote-tracking branch 'giteaofficial/main'
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
zjjhot committed Feb 2, 2024
2 parents 372bce6 + 71422c0 commit 098f110
Show file tree
Hide file tree
Showing 14 changed files with 34 additions and 44 deletions.
8 changes: 0 additions & 8 deletions routers/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@ import (
"code.gitea.io/gitea/modules/setting"
)

// RemoveUsernameParameterSuffix returns the username parameter without the (fullname) suffix - leaving just the username
func RemoveUsernameParameterSuffix(name string) string {
if index := strings.Index(name, " ("); index >= 0 {
name = name[:index]
}
return name
}

// SanitizeFlashErrorString will sanitize a flash error string
func SanitizeFlashErrorString(x string) string {
return strings.ReplaceAll(html.EscapeString(x), "\n", "<br>")
Expand Down
6 changes: 0 additions & 6 deletions routers/utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ import (
"github.com/stretchr/testify/assert"
)

func TestRemoveUsernameParameterSuffix(t *testing.T) {
assert.Equal(t, "foobar", RemoveUsernameParameterSuffix("foobar (Foo Bar)"))
assert.Equal(t, "foobar", RemoveUsernameParameterSuffix("foobar"))
assert.Equal(t, "", RemoveUsernameParameterSuffix(""))
}

func TestIsExternalURL(t *testing.T) {
setting.AppURL = "https://try.gitea.io/"
type test struct {
Expand Down
3 changes: 1 addition & 2 deletions routers/web/org/teams.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/web"
"code.gitea.io/gitea/routers/utils"
shared_user "code.gitea.io/gitea/routers/web/shared/user"
"code.gitea.io/gitea/services/convert"
"code.gitea.io/gitea/services/forms"
Expand Down Expand Up @@ -127,7 +126,7 @@ func TeamsAction(ctx *context.Context) {
ctx.Error(http.StatusNotFound)
return
}
uname := utils.RemoveUsernameParameterSuffix(strings.ToLower(ctx.FormString("uname")))
uname := strings.ToLower(ctx.FormString("uname"))
var u *user_model.User
u, err = user_model.GetUserByName(ctx, uname)
if err != nil {
Expand Down
5 changes: 2 additions & 3 deletions routers/web/repo/setting/collaboration.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"code.gitea.io/gitea/modules/log"
repo_module "code.gitea.io/gitea/modules/repository"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/routers/utils"
"code.gitea.io/gitea/services/mailer"
org_service "code.gitea.io/gitea/services/org"
repo_service "code.gitea.io/gitea/services/repository"
Expand Down Expand Up @@ -52,7 +51,7 @@ func Collaboration(ctx *context.Context) {

// CollaborationPost response for actions for a collaboration of a repository
func CollaborationPost(ctx *context.Context) {
name := utils.RemoveUsernameParameterSuffix(strings.ToLower(ctx.FormString("collaborator")))
name := strings.ToLower(ctx.FormString("collaborator"))
if len(name) == 0 || ctx.Repo.Owner.LowerName == name {
ctx.Redirect(setting.AppSubURL + ctx.Req.URL.EscapedPath())
return
Expand Down Expand Up @@ -144,7 +143,7 @@ func AddTeamPost(ctx *context.Context) {
return
}

name := utils.RemoveUsernameParameterSuffix(strings.ToLower(ctx.FormString("team")))
name := strings.ToLower(ctx.FormString("team"))
if len(name) == 0 {
ctx.Redirect(ctx.Repo.RepoLink + "/settings/collaboration")
return
Expand Down
15 changes: 7 additions & 8 deletions services/release/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,15 +291,13 @@ func UpdateRelease(ctx context.Context, doer *user_model.User, gitRepo *git.Repo
}
}

if !isCreated {
notify_service.UpdateRelease(gitRepo.Ctx, doer, rel)
return nil
}

if !rel.IsDraft {
if !isCreated {
notify_service.UpdateRelease(gitRepo.Ctx, doer, rel)
return nil
}
notify_service.NewRelease(gitRepo.Ctx, rel)
}

return nil
}

Expand Down Expand Up @@ -368,8 +366,9 @@ func DeleteReleaseByID(ctx context.Context, repo *repo_model.Repository, rel *re
}
}

notify_service.DeleteRelease(ctx, doer, rel)

if !rel.IsDraft {
notify_service.DeleteRelease(ctx, doer, rel)
}
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions templates/repo/commit_load_branches_and_tags.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
<div>{{ctx.Locale.Tr "repo.commit.contained_in"}}</div>
<div class="gt-df gt-mt-3">
<div class="gt-p-2">{{svg "octicon-git-branch"}}</div>
<div class="branch-area flex-text-block gt-f1"></div>
<div class="branch-area flex-text-block gt-fw gt-f1"></div>
</div>
<div class="gt-df gt-mt-3">
<div class="gt-p-2">{{svg "octicon-tag"}}</div>
<div class="tag-area flex-text-block gt-f1"></div>
<div class="tag-area flex-text-block gt-fw gt-f1"></div>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion templates/repo/settings/lfs_file.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
{{else if .IsPDFFile}}
<div class="pdf-content is-loading" data-src="{{$.RawFileLink}}" data-fallback-button-text="{{ctx.Locale.Tr "diff.view_file"}}"></div>
{{else}}
<a href="{{$.RawFileLink}}" rel="nofollow" class="btn btn-gray btn-radius">{{ctx.Locale.Tr "repo.file_view_raw"}}</a>
<a href="{{$.RawFileLink}}" rel="nofollow">{{ctx.Locale.Tr "repo.file_view_raw"}}</a>
{{end}}
</div>
{{else if .FileSize}}
Expand Down
4 changes: 2 additions & 2 deletions templates/repo/unicode_escape_prompt.tmpl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{if .EscapeStatus}}
{{if .EscapeStatus.HasInvisible}}
<div class="ui warning message unicode-escape-prompt gt-text-left">
<button class="close icon hide-panel button" data-panel-closest=".message">{{svg "octicon-x" 16 "close inside"}}</button>
<button class="btn close icon hide-panel" data-panel-closest=".message">{{svg "octicon-x" 16 "close inside"}}</button>
<div class="header">
{{ctx.Locale.Tr "repo.invisible_runes_header"}}
</div>
Expand All @@ -12,7 +12,7 @@
</div>
{{else if .EscapeStatus.HasAmbiguous}}
<div class="ui warning message unicode-escape-prompt gt-text-left">
<button class="close icon hide-panel button" data-panel-closest=".message">{{svg "octicon-x" 16 "close inside"}}</button>
<button class="btn close icon hide-panel" data-panel-closest=".message">{{svg "octicon-x" 16 "close inside"}}</button>
<div class="header">
{{ctx.Locale.Tr "repo.ambiguous_runes_header"}}
</div>
Expand Down
2 changes: 1 addition & 1 deletion templates/repo/view_file.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
{{else if .IsPDFFile}}
<div class="pdf-content is-loading" data-src="{{$.RawFileLink}}" data-fallback-button-text="{{ctx.Locale.Tr "repo.diff.view_file"}}"></div>
{{else}}
<a href="{{$.RawFileLink}}" rel="nofollow" class="btn btn-gray btn-radius">{{ctx.Locale.Tr "repo.file_view_raw"}}</a>
<a href="{{$.RawFileLink}}" rel="nofollow">{{ctx.Locale.Tr "repo.file_view_raw"}}</a>
{{end}}
</div>
{{else if .FileSize}}
Expand Down
4 changes: 4 additions & 0 deletions web_src/css/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,14 @@ a.label,
.ui.search > .results {
background: var(--color-body);
border-color: var(--color-secondary);
overflow-wrap: anywhere; /* allow text to wrap as fomantic limits this to 18em width */
}

.ui.search > .results .result {
background: var(--color-body);
border-color: var(--color-secondary);
display: flex;
align-items: center;
}

.ui.search > .results .result .title {
Expand Down
8 changes: 5 additions & 3 deletions web_src/css/repo.css
Original file line number Diff line number Diff line change
Expand Up @@ -2128,14 +2128,16 @@
}

#search-user-box .results .result .image {
float: left;
margin-right: 8px;
order: 0;
margin-right: 12px;
width: 2em;
height: 2em;
min-width: 2em;
min-height: 2em;
}

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

.ui.menu .item > img:not(.ui) {
Expand Down
9 changes: 4 additions & 5 deletions web_src/js/features/comp/SearchUserBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@ export function initCompSearchUserBox() {
const searchQuery = $searchUserBox.find('input').val();
const searchQueryUppercase = searchQuery.toUpperCase();
$.each(response.data, (_i, item) => {
let title = item.login;
if (item.full_name && item.full_name.length > 0) {
title += ` (${htmlEscape(item.full_name)})`;
}
const resultItem = {
title,
title: item.login,
image: item.avatar_url
};
if (item.full_name) {
resultItem.description = htmlEscape(item.full_name);
}
if (searchQueryUppercase === item.login.toUpperCase()) {
items.unshift(resultItem);
} else {
Expand Down
4 changes: 2 additions & 2 deletions web_src/js/features/repo-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ export function initRepoSettingSearchTeamBox() {
onResponse(response) {
const items = [];
$.each(response.data, (_i, item) => {
const title = `${item.name} (${item.permission} access)`;
items.push({
title,
title: item.name,
description: `${item.permission} access` // TODO: translate this string
});
});

Expand Down
4 changes: 3 additions & 1 deletion web_src/js/markup/codecopy.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ export function renderCodeCopy() {
if (!els.length) return;

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

0 comments on commit 098f110

Please sign in to comment.