mirror of
https://github.com/go-gitea/gitea.git
synced 2026-09-01 02:29:40 +09:00
enhance(repo): unify diff stats on commit pages, misc diff tweaks (#39134)
Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
co-authored by
silverwind
wxiaoguang
parent
8ef7a9e46d
commit
27570ea685
@@ -2593,16 +2593,21 @@
|
||||
"repo.diff.whitespace_ignore_at_eol": "Ignore changes in whitespace at EOL",
|
||||
"repo.diff.stats_desc": "<strong> %d changed files</strong> with <strong>%d additions</strong> and <strong>%d deletions</strong>",
|
||||
"repo.diff.stats_desc_file": "%d changes: %d additions and %d deletions",
|
||||
"repo.diff.num_files_changed_1": "%d file changed",
|
||||
"repo.diff.num_files_changed_n": "%d files changed",
|
||||
"repo.diff.bin": "BIN",
|
||||
"repo.diff.bin_not_shown": "Binary file not shown.",
|
||||
"repo.diff.file_renamed_no_changes": "File renamed without changes.",
|
||||
"repo.diff.file_mode_changed": "File mode changed.",
|
||||
"repo.diff.file_whitespace_only_changes": "Whitespace-only changes.",
|
||||
"repo.diff.view_file": "View File",
|
||||
"repo.diff.file_before": "Before",
|
||||
"repo.diff.file_after": "After",
|
||||
"repo.diff.file_image_width": "Width",
|
||||
"repo.diff.file_image_height": "Height",
|
||||
"repo.diff.file_byte_size": "Size",
|
||||
"repo.diff.file_suppressed": "File diff suppressed because it is too large",
|
||||
"repo.diff.file_suppressed_line_too_long": "File diff suppressed because one or more lines are too long",
|
||||
"repo.diff.file_suppressed": "File diff suppressed because it is too large.",
|
||||
"repo.diff.file_suppressed_line_too_long": "File diff suppressed because one or more lines are too long.",
|
||||
"repo.diff.too_many_files": "Loaded %[1]d of %[2]d files, more files were not shown because too many files have changed in this diff.",
|
||||
"repo.diff.show_more": "Show more",
|
||||
"repo.diff.load": "Load diff",
|
||||
@@ -2642,9 +2647,9 @@
|
||||
"repo.diff.all_file_extensions": "All extensions",
|
||||
"repo.diff.no_files_matched": "No files matched your search",
|
||||
"repo.diff.show_more_matching": "Show more - %[1]d matching below",
|
||||
"repo.diff.submodule_added": "Submodule %[1]s added at %[2]s",
|
||||
"repo.diff.submodule_deleted": "Submodule %[1]s deleted from %[2]s",
|
||||
"repo.diff.submodule_updated": "Submodule %[1]s updated: %[2]s",
|
||||
"repo.diff.submodule_added": "Submodule %[1]s added at %[2]s.",
|
||||
"repo.diff.submodule_deleted": "Submodule %[1]s deleted from %[2]s.",
|
||||
"repo.diff.submodule_updated": "Submodule %[1]s updated: %[2]s.",
|
||||
"repo.releases.desc": "Track project versions and downloads.",
|
||||
"repo.release.releases": "Releases",
|
||||
"repo.release.detail": "Release details",
|
||||
|
||||
@@ -395,6 +395,8 @@ func Diff(ctx *context.Context) {
|
||||
ctx.Data["CommitOtherParticipants"] = gituser.BuildAvatarStackData(ctx, commit.CoAuthorIdentities(), nil).Participants
|
||||
ctx.Data["Parents"] = parents
|
||||
ctx.Data["DiffNotAvailable"] = diffShortStat.NumFiles == 0
|
||||
ctx.Data["ShowDiffSummaryInToolbar"] = false
|
||||
ctx.Data["ShowDiffSummaryInCommitHeader"] = diffShortStat.NumFiles != 0
|
||||
|
||||
if err := asymkey_model.CalculateTrustStatus(verification, ctx.Repo.Repository.GetTrustModel(), func(user *user_model.User) (bool, error) {
|
||||
return repo_model.HasAccessToRepoCodeUnit(ctx, ctx.Repo.Repository, user.ID)
|
||||
|
||||
@@ -438,6 +438,7 @@ func (cpi *comparePageInfoType) prepareCompareDiff(ctx *context.Context, whitesp
|
||||
AfterCommitID: headCommitID,
|
||||
}
|
||||
ctx.Data["DiffNotAvailable"] = diffShortStat.NumFiles == 0
|
||||
ctx.Data["ShowDiffSummaryInToolbar"] = diffShortStat.NumFiles != 0
|
||||
|
||||
if !fileOnly {
|
||||
diffTree, err := gitdiff.GetDiffTree(ctx, ci.HeadGitRepo, false, beforeCommitID, headCommitID)
|
||||
|
||||
@@ -871,6 +871,7 @@ func viewPullFiles(ctx *context.Context, beforeCommitID, afterCommitID string) {
|
||||
AfterCommitID: afterCommitID,
|
||||
}
|
||||
ctx.Data["DiffNotAvailable"] = diffShortStat.NumFiles == 0
|
||||
ctx.Data["ShowDiffSummaryInToolbar"] = diffShortStat.NumFiles != 0
|
||||
|
||||
if ctx.Data["CanMarkConversation"], err = issues_model.CanMarkConversation(ctx, issue, ctx.Doer); err != nil {
|
||||
ctx.ServerError("CanMarkConversation", err)
|
||||
|
||||
@@ -125,7 +125,7 @@
|
||||
{{template "repo/commit_load_branches_and_tags" .}}
|
||||
</div>
|
||||
|
||||
<div class="ui bottom attached segment flex-text-block tw-flex-wrap">
|
||||
<div class="ui attached segment flex-text-block tw-flex-wrap">
|
||||
<div class="flex-text-inline">
|
||||
{{if .Author}}
|
||||
{{ctx.AvatarUtils.Avatar .Author 20}}
|
||||
@@ -192,6 +192,13 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{if .ShowDiffSummaryInCommitHeader}}
|
||||
<div class="ui attached segment flex-left-right">
|
||||
<strong>{{ctx.Locale.TrN .DiffShortStat.NumFiles "repo.diff.num_files_changed_1" "repo.diff.num_files_changed_n" .DiffShortStat.NumFiles}}</strong>
|
||||
{{template "repo/diff/stats" dict "Addition" .DiffShortStat.TotalAddition "Deletion" .DiffShortStat.TotalDeletion}}
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
{{if .NoteRendered}}
|
||||
<div class="ui top attached header segment git-notes">
|
||||
{{svg "octicon-note" 16 "tw-mr-2"}}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
diffTreeBtn.setAttribute('data-tooltip-content', diffTreeBtn.getAttribute(diffTreeVisible ? 'data-hide-text' : 'data-show-text'));
|
||||
</script>
|
||||
{{end}}
|
||||
{{if not .DiffNotAvailable}}
|
||||
{{if .ShowDiffSummaryInToolbar}}
|
||||
<div class="diff-detail-stats tw-flex tw-items-center tw-flex-wrap">
|
||||
{{svg "octicon-diff" 16 "tw-mr-1"}}{{ctx.Locale.Tr "repo.diff.stats_desc" .DiffShortStat.NumFiles .DiffShortStat.TotalAddition .DiffShortStat.TotalDeletion}}
|
||||
</div>
|
||||
@@ -91,13 +91,12 @@
|
||||
{{$isImage:= $file.IsBlobTypeImage}}
|
||||
{{$isCsv := $file.IsBlobTypeCsv}}
|
||||
{{$showFileViewToggle := or $isImage (and (not $file.IsIncomplete) $isCsv)}}
|
||||
{{$isExpandable := or (gt $file.Addition 0) (gt $file.Deletion 0) $file.IsBin}}
|
||||
{{$isReviewFile := and $.IsSigned $.PageIsPullFiles (not $.Repository.IsArchived) $.IsShowingAllCommits}}
|
||||
<div class="diff-file-box file-content {{TabSizeClass $.Editorconfig $file.Name}} tw-mt-0" id="diff-{{$file.NameHash}}" data-old-filename="{{$file.OldName}}" data-new-filename="{{$file.Name}}" {{if or ($file.ShouldBeHidden) (not $isExpandable)}}data-folded="true"{{end}}>
|
||||
<div class="diff-file-box file-content {{TabSizeClass $.Editorconfig $file.Name}} tw-mt-0" id="diff-{{$file.NameHash}}" data-old-filename="{{$file.OldName}}" data-new-filename="{{$file.Name}}" {{if $file.ShouldBeHidden}}data-folded="true"{{end}}>
|
||||
<div class="diff-file-header sticky-2nd-row ui top attached header">
|
||||
<div class="diff-file-name tw-flex tw-flex-1 tw-items-center tw-gap-1 tw-flex-wrap">
|
||||
<div class="flex-text-block">
|
||||
<button class="fold-file btn interact-bg tw-flex-shrink-0 tw-p-1 {{if not $isExpandable}}tw-invisible{{end}}" data-global-click="diffFileViewFold">
|
||||
<button class="fold-file btn interact-bg tw-flex-shrink-0 tw-p-1" data-global-click="diffFileViewFold">
|
||||
{{if $file.ShouldBeHidden}}
|
||||
{{svg "octicon-chevron-right" 18}}
|
||||
{{else}}
|
||||
@@ -172,7 +171,7 @@
|
||||
<div class="diff-file-body ui attached unstackable table segment" {{if and $file.IsViewed $.IsShowingAllCommits}}data-folded="true"{{end}}>
|
||||
<div id="diff-source-{{$file.NameHash}}" class="file-body file-code unicode-escaped code-diff{{if $.IsSplitStyle}} code-diff-split{{else}} code-diff-unified{{end}}{{if $showFileViewToggle}} tw-hidden{{end}}">
|
||||
{{if or $file.IsIncomplete $file.IsBin}}
|
||||
<div class="diff-file-body binary">
|
||||
<div class="tw-p-3">
|
||||
{{if $file.IsIncomplete}}
|
||||
{{if $file.IsIncompleteLineTooLong}}
|
||||
{{ctx.Locale.Tr "repo.diff.file_suppressed_line_too_long"}}
|
||||
@@ -185,7 +184,7 @@
|
||||
{{end}}
|
||||
</div>
|
||||
{{else if $file.SubmoduleDiffInfo}}
|
||||
<div class="tw-p-3">{{svg "octicon-file-submodule"}} {{$submoduleDiffInfo := $file.SubmoduleDiffInfo -}}
|
||||
<div class="tw-p-3 flex-text-block">{{svg "octicon-file-submodule"}} {{$submoduleDiffInfo := $file.SubmoduleDiffInfo -}}
|
||||
{{- $submoduleName := $submoduleDiffInfo.SubmoduleRepoLinkHTML ctx -}}
|
||||
{{- if $file.IsDeleted -}}
|
||||
{{- ctx.Locale.Tr "repo.diff.submodule_deleted" $submoduleName ($submoduleDiffInfo.CommitRefIDLinkHTML ctx $submoduleDiffInfo.PreviousRefID) -}}
|
||||
@@ -195,7 +194,7 @@
|
||||
{{- ctx.Locale.Tr "repo.diff.submodule_updated" $submoduleName ($submoduleDiffInfo.CompareRefIDLinkHTML ctx) -}}
|
||||
{{end}}
|
||||
</div>
|
||||
{{else}}
|
||||
{{else if $file.Sections}}
|
||||
<table class="chroma" data-new-comment-url="{{$.Issue.Link}}/files/reviews/new_comment" data-path="{{$file.Name}}">
|
||||
{{if $.IsSplitStyle}}
|
||||
{{template "repo/diff/section_split" dict "file" . "root" $}}
|
||||
@@ -203,6 +202,12 @@
|
||||
{{template "repo/diff/section_unified" dict "file" . "root" $}}
|
||||
{{end}}
|
||||
</table>
|
||||
{{else if $file.IsRenamed}}
|
||||
<div class="tw-p-3">{{ctx.Locale.Tr "repo.diff.file_renamed_no_changes"}}</div>
|
||||
{{else if and $file.EntryMode $file.OldEntryMode}}
|
||||
<div class="tw-p-3">{{ctx.Locale.Tr "repo.diff.file_mode_changed"}}</div>
|
||||
{{else}}
|
||||
<div class="tw-p-3">{{ctx.Locale.Tr "repo.diff.file_whitespace_only_changes"}}</div>
|
||||
{{end}}
|
||||
</div>
|
||||
{{if $showFileViewToggle}}
|
||||
|
||||
@@ -144,11 +144,8 @@
|
||||
border-top: none;
|
||||
}
|
||||
|
||||
.ui.attached.segment:has(+ .ui[class*="top attached"].header),
|
||||
.ui.attached.segment:has(+ .page.buttons),
|
||||
.ui.attached.segment:last-child,
|
||||
.ui.segment:has(+ .ui.segment:not(.attached)),
|
||||
.ui.attached.segment:has(+ .ui.modal) {
|
||||
.ui.attached.segment:has(+ :not(.ui.attached.segment)) {
|
||||
border-bottom-left-radius: 0.28571429rem;
|
||||
border-bottom-right-radius: 0.28571429rem;
|
||||
}
|
||||
|
||||
+7
-16
@@ -829,9 +829,9 @@ td .commit-summary {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 8;
|
||||
padding: 7px 5px;
|
||||
padding: 4px 5px;
|
||||
margin: 0 -5px; /* negative margin so it covers active file shadow */
|
||||
height: 44px; /* this height should match sticky-2nd-row */
|
||||
height: 41px; /* this height should match sticky-2nd-row */
|
||||
background: var(--color-body);
|
||||
}
|
||||
|
||||
@@ -840,6 +840,7 @@ td .commit-summary {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
}
|
||||
|
||||
.repository .diff-detail-box .diff-detail-stats strong {
|
||||
margin-left: 0.25rem;
|
||||
margin-right: 0.25rem;
|
||||
@@ -972,25 +973,16 @@ td .commit-summary {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.repository .diff-file-box.file-content {
|
||||
clear: right;
|
||||
}
|
||||
|
||||
.repository .diff-file-box.file-content .image-diff img {
|
||||
max-width: 100%;
|
||||
padding: 0;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.repository .diff-file-box .ui.bottom.attached.table.segment {
|
||||
padding-top: 5px;
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
|
||||
.diff-file-box {
|
||||
border: 1px solid transparent;
|
||||
border-radius: var(--border-radius);
|
||||
scroll-margin-top: 47px; /* match .repository .diff-detail-box */
|
||||
scroll-margin-top: 44px; /* .diff-detail-box height plus the :target shadow */
|
||||
}
|
||||
|
||||
.file.editor .diff-file-box {
|
||||
@@ -1549,7 +1541,6 @@ tbody.commit-list {
|
||||
|
||||
#diff-container {
|
||||
display: flex;
|
||||
padding-top: 4px; /* for box-shadow from .diff-file-box */
|
||||
gap: var(--page-spacing);
|
||||
}
|
||||
|
||||
@@ -1570,8 +1561,8 @@ tbody.commit-list {
|
||||
line-height: inherit;
|
||||
position: sticky;
|
||||
padding-top: 0;
|
||||
top: 47px;
|
||||
max-height: calc(100vh - 47px);
|
||||
top: 44px; /* match .diff-file-box scroll-margin-top */
|
||||
max-height: calc(100vh - 44px);
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -1669,7 +1660,7 @@ tbody.commit-list {
|
||||
|
||||
.ui.attached.header.diff-file-header.sticky-2nd-row {
|
||||
position: sticky;
|
||||
top: 44px; /* match .repository .diff-detail-box */
|
||||
top: 41px; /* dock right below .repository .diff-detail-box */
|
||||
z-index: 7;
|
||||
}
|
||||
|
||||
|
||||
@@ -114,10 +114,6 @@
|
||||
margin: 0 0 0 3em;
|
||||
}
|
||||
|
||||
.diff-file-body.binary {
|
||||
padding: 5px 10px;
|
||||
}
|
||||
|
||||
.file-comment {
|
||||
color: var(--color-text);
|
||||
}
|
||||
|
||||
@@ -114,7 +114,6 @@ function updateState(visible: boolean) {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
margin-right: .5rem;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
}
|
||||
@@ -124,7 +123,6 @@ function updateState(visible: boolean) {
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding-top: 1px; /* match .diff-file-box's top border so this row aligns with .diff-file-header */
|
||||
padding-bottom: 0.25rem;
|
||||
}
|
||||
|
||||
.diff-file-search-wrapper {
|
||||
|
||||
Reference in New Issue
Block a user