Skip to content

Commit

Permalink
Merge remote-tracking branch 'giteaofficial/main'
Browse files Browse the repository at this point in the history
* giteaofficial/main:
  Convert git commit summary to valid UTF8. (go-gitea#28356)
  Fix RPM/Debian signature key creation (go-gitea#28352)
  Refactor template empty checks (go-gitea#28351)
  • Loading branch information
zjjhot committed Dec 5, 2023
2 parents d5beeff + 38a93a0 commit 8fcd936
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 28 deletions.
3 changes: 2 additions & 1 deletion modules/git/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ func (c *Commit) Message() string {
}

// Summary returns first line of commit message.
// The string is forced to be valid UTF8
func (c *Commit) Summary() string {
return strings.Split(strings.TrimSpace(c.CommitMessage), "\n")[0]
return strings.ToValidUTF8(strings.Split(strings.TrimSpace(c.CommitMessage), "\n")[0], "?")
}

// ParentID returns oid of n-th parent (0-based index).
Expand Down
2 changes: 1 addition & 1 deletion services/packages/debian/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func GetOrCreateKeyPair(ctx context.Context, ownerID int64) (string, string, err
}

func generateKeypair() (string, string, error) {
e, err := openpgp.NewEntity(setting.AppName, "Debian Registry", "", nil)
e, err := openpgp.NewEntity("", "Debian Registry", "", nil)
if err != nil {
return "", "", err
}
Expand Down
5 changes: 2 additions & 3 deletions services/packages/rpm/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"code.gitea.io/gitea/modules/json"
packages_module "code.gitea.io/gitea/modules/packages"
rpm_module "code.gitea.io/gitea/modules/packages/rpm"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/util"
packages_service "code.gitea.io/gitea/services/packages"

Expand Down Expand Up @@ -68,7 +67,7 @@ func GetOrCreateKeyPair(ctx context.Context, ownerID int64) (string, string, err
}

func generateKeypair() (string, string, error) {
e, err := openpgp.NewEntity(setting.AppName, "RPM Registry", "", nil)
e, err := openpgp.NewEntity("", "RPM Registry", "", nil)
if err != nil {
return "", "", err
}
Expand Down Expand Up @@ -126,7 +125,7 @@ type packageData struct {

type packageCache = map[*packages_model.PackageFile]*packageData

// BuildSpecificRepositoryFiles builds metadata files for the repository
// BuildRepositoryFiles builds metadata files for the repository
func BuildRepositoryFiles(ctx context.Context, ownerID int64) error {
pv, err := GetOrCreateRepositoryVersion(ctx, ownerID)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion templates/repo/actions/runs_list.tmpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="flex-list">
{{if eq (len .Runs) 0}}
{{if not .Runs}}
<div class="empty-placeholder">
{{svg "octicon-no-entry" 48}}
<h2>{{if $.IsFiltered}}{{ctx.Locale.Tr "actions.runs.no_results"}}{{else}}{{ctx.Locale.Tr "actions.runs.no_runs"}}{{end}}</h2>
Expand Down
22 changes: 11 additions & 11 deletions templates/repo/diff/section_split.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -108,39 +108,39 @@
</tr>
{{if and (eq .GetType 3) $hasmatch}}
{{$match := index $section.Lines $line.Match}}
{{if or (gt (len $line.Comments) 0) (gt (len $match.Comments) 0)}}
{{if or $line.Comments $match.Comments}}
<tr class="add-comment" data-line-type="{{.GetHTMLDiffLineType}}">
<td class="add-comment-left" colspan="4">
{{if gt (len $line.Comments) 0}}
{{if $line.Comments}}
{{if eq $line.GetCommentSide "previous"}}
{{template "repo/diff/conversation" dict "." $.root "comments" $line.Comments}}
{{end}}
{{end}}
{{if gt (len $match.Comments) 0}}
{{if $match.Comments}}
{{if eq $match.GetCommentSide "previous"}}
{{template "repo/diff/conversation" dict "." $.root "comments" $match.Comments}}
{{end}}
{{end}}
</td>
<td class="add-comment-right" colspan="4">
{{if eq $line.GetCommentSide "proposed"}}
{{template "repo/diff/conversation" dict "." $.root "comments" $line.Comments}}
{{if $line.Comments}}
{{if eq $line.GetCommentSide "proposed"}}
{{template "repo/diff/conversation" dict "." $.root "comments" $line.Comments}}
{{end}}
{{end}}
{{if gt (len $match.Comments) 0}}
{{if $match.Comments}}
{{if eq $match.GetCommentSide "proposed"}}
{{template "repo/diff/conversation" dict "." $.root "comments" $match.Comments}}
{{end}}
{{end}}
</td>
</tr>
{{end}}
{{else if gt (len $line.Comments) 0}}
{{else if $line.Comments}}
<tr class="add-comment" data-line-type="{{.GetHTMLDiffLineType}}">
<td class="add-comment-left" colspan="4">
{{if gt (len $line.Comments) 0}}
{{if eq $line.GetCommentSide "previous"}}
{{template "repo/diff/conversation" dict "." $.root "comments" $line.Comments}}
{{end}}
{{if eq $line.GetCommentSide "previous"}}
{{template "repo/diff/conversation" dict "." $.root "comments" $line.Comments}}
{{end}}
</td>
<td class="add-comment-right" colspan="4">
Expand Down
2 changes: 1 addition & 1 deletion templates/repo/diff/section_unified.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
*/}}</td>
{{end}}
</tr>
{{if gt (len $line.Comments) 0}}
{{if $line.Comments}}
<tr class="add-comment" data-line-type="{{.GetHTMLDiffLineType}}">
<td class="add-comment-left add-comment-right" colspan="5">
{{template "repo/diff/conversation" dict "." $.root "comments" $line.Comments}}
Expand Down
6 changes: 3 additions & 3 deletions templates/repo/header.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@
{{end}}
{{if and (not .IsEmpty) ($.Permission.CanRead $.UnitTypeCode)}}
<div class="ui labeled button
{{if or (not $.IsSigned) (and (not $.CanSignedUserFork) (eq (len $.UserAndOrgForks) 0))}}
{{if or (not $.IsSigned) (and (not $.CanSignedUserFork) (not $.UserAndOrgForks))}}
disabled
{{end}}"
{{if not $.IsSigned}}
data-tooltip-content="{{ctx.Locale.Tr "repo.fork_guest_user"}}"
{{else if and (not $.CanSignedUserFork) (eq (len $.UserAndOrgForks) 0)}}
{{else if and (not $.CanSignedUserFork) (not $.UserAndOrgForks)}}
data-tooltip-content="{{ctx.Locale.Tr "repo.fork_from_self"}}"
{{end}}
>
Expand All @@ -98,7 +98,7 @@
href="{{AppSubUrl}}/{{(index $.UserAndOrgForks 0).FullName}}"
{{/*else is not required here, because the button shouldn't link to any site if you can't create a fork*/}}
{{end}}
{{else if eq (len $.UserAndOrgForks) 0}}
{{else if not $.UserAndOrgForks}}
href="{{AppSubUrl}}/repo/fork/{{.ID}}"
{{else}}
data-modal="#fork-repo-modal"
Expand Down
2 changes: 1 addition & 1 deletion templates/repo/issue/filters.tmpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div id="issue-filters" class="issue-list-toolbar">
<div class="issue-list-toolbar-left">
{{if and ($.CanWriteIssuesOrPulls) (gt (len .Issues) 0)}}
{{if and $.CanWriteIssuesOrPulls .Issues}}
<input type="checkbox" autocomplete="off" class="issue-checkbox-all gt-mr-4" title="{{ctx.Locale.Tr "repo.issues.action_check_all"}}">
{{end}}
{{template "repo/issue/openclose" .}}
Expand Down
2 changes: 1 addition & 1 deletion templates/repo/issue/view_content/sidebar.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@
</div>
</div>
{{end}}
{{if gt (len .WorkingUsers) 0}}
{{if .WorkingUsers}}
<div class="divider"></div>
<div class="ui comments">
<span class="text"><strong>{{ctx.Locale.Tr "repo.issues.time_spent_from_all_authors" ($.Issue.TotalTrackedTime | Sec2Time) | Safe}}</strong></span>
Expand Down
2 changes: 1 addition & 1 deletion templates/shared/issuelist.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
{{ctx.Locale.TrN $waitingOfficial "repo.pulls.waiting_count_1" "repo.pulls.waiting_count_n" $waitingOfficial}}
</span>
{{end}}
{{if and (not .PullRequest.HasMerged) (gt (len .PullRequest.ConflictedFiles) 0)}}
{{if and (not .PullRequest.HasMerged) .PullRequest.ConflictedFiles}}
<span class="conflicting flex-text-inline">
{{svg "octicon-x" 14}}
{{ctx.Locale.TrN (len .PullRequest.ConflictedFiles) "repo.pulls.num_conflicting_files_1" "repo.pulls.num_conflicting_files_n" (len .PullRequest.ConflictedFiles)}}
Expand Down
2 changes: 1 addition & 1 deletion templates/user/dashboard/feeds.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
{{else if .GetOpType.InActions "comment_issue" "approve_pull_request" "reject_pull_request" "comment_pull"}}
<a href="{{.GetCommentLink ctx}}" class="text truncate issue title">{{(.GetIssueTitle ctx) | RenderEmoji $.Context | RenderCodeBlock}}</a>
{{$comment := index .GetIssueInfos 1}}
{{if gt (len $comment) 0}}
{{if $comment}}
<div class="markup gt-font-14">{{RenderMarkdownToHtml ctx $comment}}</div>
{{end}}
{{else if .GetOpType.InActions "merge_pull_request"}}
Expand Down
2 changes: 1 addition & 1 deletion templates/user/notification/notification_div.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</div>
<div class="gt-p-0">
<div id="notification_table">
{{if eq (len .Notifications) 0}}
{{if not .Notifications}}
<div class="gt-df gt-ac gt-fc gt-p-4">
{{svg "octicon-inbox" 56 "gt-mb-4"}}
{{if eq .Status 1}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
</div>
</div>
<div class="divider"></div>
{{if eq (len .Issues) 0}}
{{if not .Issues}}
{{ctx.Locale.Tr "notification.no_subscriptions"}}
{{else}}
{{template "shared/issuelist" dict "." . "listType" "dashboard"}}
Expand Down
2 changes: 1 addition & 1 deletion templates/user/settings/keys_gpg.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
{{if .Verified}}
<span class="flex-text-block" data-tooltip-content="{{ctx.Locale.Tr "settings.gpg_key_verified_long"}}">{{svg "octicon-verified"}} <strong>{{ctx.Locale.Tr "settings.gpg_key_verified"}}</strong></span>
{{end}}
{{if gt (len .Emails) 0}}
{{if .Emails}}
<span class="flex-text-block" data-tooltip-content="{{ctx.Locale.Tr "settings.gpg_key_matched_identities_long"}}">{{svg "octicon-mail"}} {{ctx.Locale.Tr "settings.gpg_key_matched_identities"}} {{range .Emails}}<strong>{{.Email}} </strong>{{end}}</span>
{{end}}
<div class="flex-item-body">
Expand Down

0 comments on commit 8fcd936

Please sign in to comment.