2023-10-25 05:09:18 +02:00
{{ $showFileTree := ( and ( not .DiffNotAvailable ) ( gt .Diff.NumFiles 1 )) }}
2023-07-06 17:33:04 +02:00
< div >
2023-09-28 18:00:26 +08:00
< div class = "diff-detail-box diff-box" >
Migrate margin and padding helpers to tailwind (#30043)
This will conclude the refactor of 1:1 class replacements to tailwind,
except `gt-hidden`. Commands ran:
```bash
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-0#tw-$1$2-0#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-1#tw-$1$2-0.5#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-2#tw-$1$2-1#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-3#tw-$1$2-2#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-4#tw-$1$2-4#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-5#tw-$1$2-8#g' {web_src/js,templates,routers,services}/**/*
```
(cherry picked from commit 68ec9b48592fe88765bcc3a73093d43c98b315de)
Conflicts:
routers/web/repo/view.go
templates/base/head_navbar.tmpl
templates/repo/code/recently_pushed_new_branches.tmpl
templates/repo/diff/box.tmpl
templates/repo/diff/compare.tmpl
templates/repo/diff/conversation.tmpl
templates/repo/header.tmpl
templates/repo/issue/filter_list.tmpl
templates/repo/issue/view_content/conversation.tmpl
templates/repo/issue/view_content/sidebar.tmpl
templates/repo/settings/options.tmpl
templates/repo/view_file.tmpl
templates/shared/user/blocked_users.tmpl
templates/status/500.tmpl
web_src/js/components/DashboardRepoList.vue
resolved by prefering Forgejo version and applying the
commands to all files
2024-03-24 17:42:49 +01:00
< div class = "tw-flex tw-items-center tw-flex-wrap tw-gap-2 tw-ml-0.5" >
2023-10-25 05:09:18 +02:00
{{ if $showFileTree }}
2023-11-17 19:35:51 +01:00
< button class = "diff-toggle-file-tree-button not-mobile btn interact-fg" data-show-text = " {{ ctx .Locale.Tr "repo.diff.show_file_tree" }} " data-hide-text = " {{ ctx .Locale.Tr "repo.diff.hide_file_tree" }} " >
2022-10-14 11:43:25 +02:00
{{/* the icon meaning is reversed here, "octicon-sidebar-collapse" means show the file tree */}}
2024-03-24 19:23:38 +01:00
{{ svg "octicon-sidebar-collapse" 20 "icon tw-hidden" }}
{{ svg "octicon-sidebar-expand" 20 "icon tw-hidden" }}
2023-03-30 14:06:10 +02:00
< / button >
< script >
2023-06-02 11:39:01 -04:00
// Default to true if unset
const diffTreeVisible = localStorage?.getItem('diff_file_tree_visible') !== 'false';
2023-03-30 14:06:10 +02:00
const diffTreeBtn = document.querySelector('.diff-toggle-file-tree-button');
const diffTreeIcon = `.octicon-sidebar-${diffTreeVisible ? 'expand' : 'collapse'}`;
2024-03-24 19:23:38 +01:00
diffTreeBtn.querySelector(diffTreeIcon).classList.remove('tw-hidden');
2023-03-30 14:06:10 +02:00
diffTreeBtn.setAttribute('data-tooltip-content', diffTreeBtn.getAttribute(diffTreeVisible ? 'data-hide-text' : 'data-show-text'));
< / script >
2023-10-25 05:09:18 +02:00
{{ end }}
{{ if not .DiffNotAvailable }}
2024-03-22 20:51:29 +01:00
< div class = "diff-detail-stats tw-flex tw-items-center tw-flex-wrap" >
Migrate margin and padding helpers to tailwind (#30043)
This will conclude the refactor of 1:1 class replacements to tailwind,
except `gt-hidden`. Commands ran:
```bash
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-0#tw-$1$2-0#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-1#tw-$1$2-0.5#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-2#tw-$1$2-1#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-3#tw-$1$2-2#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-4#tw-$1$2-4#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-5#tw-$1$2-8#g' {web_src/js,templates,routers,services}/**/*
```
(cherry picked from commit 68ec9b48592fe88765bcc3a73093d43c98b315de)
Conflicts:
routers/web/repo/view.go
templates/base/head_navbar.tmpl
templates/repo/code/recently_pushed_new_branches.tmpl
templates/repo/diff/box.tmpl
templates/repo/diff/compare.tmpl
templates/repo/diff/conversation.tmpl
templates/repo/header.tmpl
templates/repo/issue/filter_list.tmpl
templates/repo/issue/view_content/conversation.tmpl
templates/repo/issue/view_content/sidebar.tmpl
templates/repo/settings/options.tmpl
templates/repo/view_file.tmpl
templates/shared/user/blocked_users.tmpl
templates/status/500.tmpl
web_src/js/components/DashboardRepoList.vue
resolved by prefering Forgejo version and applying the
commands to all files
2024-03-24 17:42:49 +01:00
{{ svg "octicon-diff" 16 "tw-mr-1" }}{{ ctx .Locale.Tr "repo.diff.stats_desc" .Diff.NumFiles .Diff.TotalAddition .Diff.TotalDeletion }}
2022-10-14 11:43:25 +02:00
< / div >
2023-07-06 17:33:04 +02:00
{{ end }}
2015-12-07 23:30:52 +01:00
< / div >
2024-07-07 03:21:58 +00:00
< div class = "diff-detail-actions button-row" >
2023-07-06 17:33:04 +02:00
{{ if and .PageIsPullFiles $.SignedUserID ( not .IsArchived ) ( not .DiffNotAvailable ) }}
Migrate margin and padding helpers to tailwind (#30043)
This will conclude the refactor of 1:1 class replacements to tailwind,
except `gt-hidden`. Commands ran:
```bash
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-0#tw-$1$2-0#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-1#tw-$1$2-0.5#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-2#tw-$1$2-1#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-3#tw-$1$2-2#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-4#tw-$1$2-4#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-5#tw-$1$2-8#g' {web_src/js,templates,routers,services}/**/*
```
(cherry picked from commit 68ec9b48592fe88765bcc3a73093d43c98b315de)
Conflicts:
routers/web/repo/view.go
templates/base/head_navbar.tmpl
templates/repo/code/recently_pushed_new_branches.tmpl
templates/repo/diff/box.tmpl
templates/repo/diff/compare.tmpl
templates/repo/diff/conversation.tmpl
templates/repo/header.tmpl
templates/repo/issue/filter_list.tmpl
templates/repo/issue/view_content/conversation.tmpl
templates/repo/issue/view_content/sidebar.tmpl
templates/repo/settings/options.tmpl
templates/repo/view_file.tmpl
templates/shared/user/blocked_users.tmpl
templates/status/500.tmpl
web_src/js/components/DashboardRepoList.vue
resolved by prefering Forgejo version and applying the
commands to all files
2024-03-24 17:42:49 +01:00
< div class = "not-mobile tw-flex tw-items-center tw-flex-col tw-whitespace-nowrap tw-mr-1" >
2023-09-25 10:56:50 +02:00
< label for = "viewed-files-summary" id = "viewed-files-summary-label" data-text-changed-template = " {{ ctx .Locale.Tr "repo.pulls.viewed_files_label" }} " >
{{ ctx .Locale.Tr "repo.pulls.viewed_files_label" .Diff.NumViewedFiles .Diff.NumFiles }}
2023-07-06 17:33:04 +02:00
< / label >
< progress id = "viewed-files-summary" value = " {{ .Diff.NumViewedFiles }} " max = " {{ .Diff.NumFiles }} " ></ progress >
< / div >
{{ end }}
{{ template "repo/diff/whitespace_dropdown" . }}
{{ template "repo/diff/options_dropdown" . }}
2023-07-28 21:18:12 +02:00
{{ if .PageIsPullFiles }}
2023-09-25 10:56:50 +02:00
< div id = "diff-commit-select" data-issuelink = " {{ $.Issue.Link }} " data-queryparams = "?style= {{ if $.IsSplitStyle }} split {{ else }} unified {{ end }} &whitespace= {{ $.WhitespaceBehavior }} &show-outdated= {{ $.ShowOutdatedComments }} " data-filter_changes_by_commit = " {{ ctx .Locale.Tr "repo.pulls.filter_changes_by_commit" }} " >
2023-07-28 21:18:12 +02:00
{{ /*
the following will be replaced by vue component
but this avoids any loading artifacts till the vue component is initialized
*/}}
< div class = "ui jump dropdown basic button custom" >
{{ svg "octicon-git-commit" }}
< / div >
< / div >
{{ end }}
2023-07-06 17:33:04 +02:00
{{ if and .PageIsPullFiles $.SignedUserID ( not .IsArchived ) }}
{{ template "repo/diff/new_review" . }}
{{ end }}
< / div >
< / div >
{{ if not .DiffNotAvailable }}
2023-07-28 21:18:12 +02:00
{{ if and .IsShowingOnlySingleCommit .PageIsPullFiles }}
< div class = "ui info message" >
2025-06-17 09:31:50 +02:00
< div > {{ ctx .Locale.Tr "repo.pulls.showing_only_single_commit" ( ShortSha .CommitID ) }} - < a href = " {{ $.Issue.Link }} /files?style= {{ if $.IsSplitStyle }} split {{ else }} unified {{ end }} &whitespace= {{ $.WhitespaceBehavior }} &show-outdated= {{ $.ShowOutdatedComments }} " > {{ ctx .Locale.Tr "repo.pulls.show_all_commits" }} </ a ></ div >
2023-07-28 21:18:12 +02:00
< / div >
{{ else if and ( not .IsShowingAllCommits ) .PageIsPullFiles }}
< div class = "ui info message" >
2023-09-25 20:42:40 +08:00
< div > {{ ctx .Locale.Tr "repo.pulls.showing_specified_commit_range" ( ShortSha .BeforeCommitID ) ( ShortSha .AfterCommitID ) }} - < a href = " {{ $.Issue.Link }} /files?style= {{ if $.IsSplitStyle }} split {{ else }} unified {{ end }} &whitespace= {{ $.WhitespaceBehavior }} &show-outdated= {{ $.ShowOutdatedComments }} " > {{ ctx .Locale.Tr "repo.pulls.show_all_commits" }} </ a ></ div >
2023-07-28 21:18:12 +02:00
< / div >
{{ end }}
2023-05-30 18:53:15 +08:00
< script id = "diff-data-script" type = "module" >
2023-06-25 02:46:30 +02:00
const diffDataFiles = [{{ range $i , $file := .Diff.Files }} {Name:"{{ $file .Name }} ",NameHash:"{{ $file .NameHash }} ",Type:{{ $file .Type }} ,IsBin:{{ $file .IsBin }} ,Addition:{{ $file .Addition }} ,Deletion:{{ $file .Deletion }} ,IsViewed:{{ $file .IsViewed }} },{{ end }} ];
2023-05-30 18:53:15 +08:00
const diffData = {
isIncomplete: {{ .Diff.IsIncomplete }} ,
2023-09-25 10:56:50 +02:00
tooManyFilesMessage: "{{ ctx .Locale.Tr "repo.diff.too_many_files" }} ",
binaryFileMessage: "{{ ctx .Locale.Tr "repo.diff.bin" }} ",
showMoreMessage: "{{ ctx .Locale.Tr "repo.diff.show_more" }} ",
statisticsMessage: "{{ ctx .Locale.Tr "repo.diff.stats_desc_file" }} ",
2024-03-20 13:56:42 +08:00
linkLoadMore: "?skip-to={{ .Diff.End }} & file-only=true",
2023-05-30 18:53:15 +08:00
};
// for first time loading, the diffFileInfo is a plain object
// after the Vue component is mounted, the diffFileInfo is a reactive object
// keep in mind that this script block would be executed many times when loading more files, by "loadMoreFiles"
let diffFileInfo = window.config.pageData.diffFileInfo || {
files:[],
fileTreeIsVisible: false,
fileListIsVisible: false,
isLoadingNewData: false,
selectedItem: '',
};
diffFileInfo = Object.assign(diffFileInfo, diffData);
diffFileInfo.files.push(...diffDataFiles);
window.config.pageData.diffFileInfo = diffFileInfo;
< / script >
2023-07-06 17:33:04 +02:00
{{ end }}
< div id = "diff-container" >
2023-10-25 05:09:18 +02:00
{{ if $showFileTree }}
2024-03-24 19:23:38 +01:00
< div id = "diff-file-tree" class = "tw-hidden not-mobile" > < / div >
2023-07-06 17:33:04 +02:00
< script >
2024-03-24 19:23:38 +01:00
if (diffTreeVisible) document.getElementById('diff-file-tree').classList.remove('tw-hidden');
2023-07-06 17:33:04 +02:00
< / script >
2023-10-25 05:09:18 +02:00
{{ end }}
2025-06-17 09:31:50 +02:00
< div id = "diff-content-container" >
{{ if .IsShowingOnlySingleCommit }}
< div id = "diff-commit-header" >
{{ template "repo/commit_header" . }}
< / div >
{{ end }}
2023-10-25 05:09:18 +02:00
{{ if .DiffNotAvailable }}
< h4 > {{ ctx .Locale.Tr "repo.diff.data_not_available" }} </ h4 >
{{ else }}
2023-07-06 17:33:04 +02:00
< div id = "diff-file-boxes" class = "sixteen wide column" >
{{ range $i , $file := .Diff.Files }}
{{/*notice: the index of Diff.Files should not be used for element ID, because the index will be restarted from 0 when doing load-more for PRs with a lot of files*/}}
{{ $blobBase := call $.GetBlobByPathForCommit $.BeforeCommit $file .OldName }}
{{ $blobHead := call $.GetBlobByPathForCommit $.HeadCommit $file .Name }}
2023-10-11 14:34:21 +02:00
{{ $sniffedTypeBase := call $.GetSniffedTypeForBlob $blobBase }}
{{ $sniffedTypeHead := call $.GetSniffedTypeForBlob $blobHead }}
{{ $isImage := or ( call $.IsSniffedTypeAnImage $sniffedTypeBase ) ( call $.IsSniffedTypeAnImage $sniffedTypeHead ) }}
2023-07-06 17:33:04 +02:00
{{ $isCsv := ( call $.IsCsvFile $file ) }}
{{ $showFileViewToggle := or $isImage ( and ( not $file .IsIncomplete ) $isCsv ) }}
{{ $isExpandable := or ( gt $file .Addition 0 ) ( gt $file .Deletion 0 ) $file .IsBin }}
2023-07-28 21:18:12 +02:00
{{ $isReviewFile := and $.IsSigned $.PageIsPullFiles ( not $.IsArchived ) $.IsShowingAllCommits }}
Migrate margin and padding helpers to tailwind (#30043)
This will conclude the refactor of 1:1 class replacements to tailwind,
except `gt-hidden`. Commands ran:
```bash
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-0#tw-$1$2-0#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-1#tw-$1$2-0.5#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-2#tw-$1$2-1#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-3#tw-$1$2-2#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-4#tw-$1$2-4#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-5#tw-$1$2-8#g' {web_src/js,templates,routers,services}/**/*
```
(cherry picked from commit 68ec9b48592fe88765bcc3a73093d43c98b315de)
Conflicts:
routers/web/repo/view.go
templates/base/head_navbar.tmpl
templates/repo/code/recently_pushed_new_branches.tmpl
templates/repo/diff/box.tmpl
templates/repo/diff/compare.tmpl
templates/repo/diff/conversation.tmpl
templates/repo/header.tmpl
templates/repo/issue/filter_list.tmpl
templates/repo/issue/view_content/conversation.tmpl
templates/repo/issue/view_content/sidebar.tmpl
templates/repo/settings/options.tmpl
templates/repo/view_file.tmpl
templates/shared/user/blocked_users.tmpl
templates/status/500.tmpl
web_src/js/components/DashboardRepoList.vue
resolved by prefering Forgejo version and applying the
commands to all files
2024-03-24 17:42:49 +01:00
< div class = "diff-file-box diff-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 }} >
2024-03-24 14:32:19 +01:00
< h4 class = "diff-file-header sticky-2nd-row ui top attached header tw-font-normal tw-flex tw-items-center tw-justify-between tw-flex-wrap" >
2024-04-10 08:13:22 +02:00
< div class = "diff-file-name tw-flex tw-flex-1 tw-items-center tw-gap-1 tw-flex-wrap" >
Migrate margin and padding helpers to tailwind (#30043)
This will conclude the refactor of 1:1 class replacements to tailwind,
except `gt-hidden`. Commands ran:
```bash
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-0#tw-$1$2-0#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-1#tw-$1$2-0.5#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-2#tw-$1$2-1#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-3#tw-$1$2-2#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-4#tw-$1$2-4#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-5#tw-$1$2-8#g' {web_src/js,templates,routers,services}/**/*
```
(cherry picked from commit 68ec9b48592fe88765bcc3a73093d43c98b315de)
Conflicts:
routers/web/repo/view.go
templates/base/head_navbar.tmpl
templates/repo/code/recently_pushed_new_branches.tmpl
templates/repo/diff/box.tmpl
templates/repo/diff/compare.tmpl
templates/repo/diff/conversation.tmpl
templates/repo/header.tmpl
templates/repo/issue/filter_list.tmpl
templates/repo/issue/view_content/conversation.tmpl
templates/repo/issue/view_content/sidebar.tmpl
templates/repo/settings/options.tmpl
templates/repo/view_file.tmpl
templates/shared/user/blocked_users.tmpl
templates/status/500.tmpl
web_src/js/components/DashboardRepoList.vue
resolved by prefering Forgejo version and applying the
commands to all files
2024-03-24 17:42:49 +01:00
< button class = "fold-file btn interact-bg tw-p-1 {{ if not $isExpandable }} tw-invisible {{ end }} " >
2023-07-06 17:33:04 +02:00
{{ if $file .ShouldBeHidden }}
{{ svg "octicon-chevron-right" 18 }}
{{ else }}
{{ svg "octicon-chevron-down" 18 }}
2022-09-27 07:22:19 +02:00
{{ end }}
2023-07-06 17:33:04 +02:00
< / button >
2024-03-28 09:31:07 +01:00
< div class = "tw-font-semibold tw-flex tw-items-center tw-font-mono" >
2023-07-06 17:33:04 +02:00
{{ if $file .IsBin }}
Migrate margin and padding helpers to tailwind (#30043)
This will conclude the refactor of 1:1 class replacements to tailwind,
except `gt-hidden`. Commands ran:
```bash
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-0#tw-$1$2-0#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-1#tw-$1$2-0.5#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-2#tw-$1$2-1#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-3#tw-$1$2-2#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-4#tw-$1$2-4#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-5#tw-$1$2-8#g' {web_src/js,templates,routers,services}/**/*
```
(cherry picked from commit 68ec9b48592fe88765bcc3a73093d43c98b315de)
Conflicts:
routers/web/repo/view.go
templates/base/head_navbar.tmpl
templates/repo/code/recently_pushed_new_branches.tmpl
templates/repo/diff/box.tmpl
templates/repo/diff/compare.tmpl
templates/repo/diff/conversation.tmpl
templates/repo/header.tmpl
templates/repo/issue/filter_list.tmpl
templates/repo/issue/view_content/conversation.tmpl
templates/repo/issue/view_content/sidebar.tmpl
templates/repo/settings/options.tmpl
templates/repo/view_file.tmpl
templates/shared/user/blocked_users.tmpl
templates/status/500.tmpl
web_src/js/components/DashboardRepoList.vue
resolved by prefering Forgejo version and applying the
commands to all files
2024-03-24 17:42:49 +01:00
< span class = "tw-ml-0.5 tw-mr-2" >
2023-09-25 10:56:50 +02:00
{{ ctx .Locale.Tr "repo.diff.bin" }}
2023-07-06 17:33:04 +02:00
< / span >
2021-06-05 14:32:19 +02:00
{{ else }}
2023-07-06 17:33:04 +02:00
{{ template "repo/diff/stats" dict "file" . "root" $ }}
2021-06-05 14:32:19 +02:00
{{ end }}
2022-09-27 07:22:19 +02:00
< / div >
2024-04-10 08:13:22 +02:00
< span class = "file tw-flex tw-items-center tw-font-mono tw-flex-1" >< a class = "muted file-link" title = " {{ if $file .IsRenamed }}{{ $file .OldName }} → {{ end }}{{ $file .Name }} " href = "#diff- {{ $file .NameHash }} " > {{ if $file .IsRenamed }}{{ $file .OldName }} → {{ end }}{{ $file .Name }} </ a >
{{ if .IsLFSFile }} ({{ ctx .Locale.Tr "repo.stored_lfs" }} ){{ end }}
2024-12-09 19:32:16 +00:00
< button class = "btn interact-fg tw-p-2" data-clipboard-text = " {{ $file .Name }} " data-tooltip-content = " {{ ctx .Locale.Tr "copy_path" }} " > {{ svg "octicon-copy" 14 }} </ button >
2024-04-10 08:13:22 +02:00
{{ if $file .IsGenerated }}
< span class = "ui label" > {{ ctx .Locale.Tr "repo.diff.generated" }} </ span >
{{ end }}
{{ if $file .IsVendored }}
< span class = "ui label" > {{ ctx .Locale.Tr "repo.diff.vendored" }} </ span >
{{ end }}
{{ if and $file .Mode $file .OldMode }}
{{ $old := ctx .Locale.Tr ( $file .ModeTranslationKey $file .OldMode ) }}
{{ $new := ctx .Locale.Tr ( $file .ModeTranslationKey $file .Mode ) }}
< span class = "tw-mx-2 tw-font-mono tw-whitespace-nowrap" > {{ ctx .Locale.Tr "git.filemode.changed_filemode" $old $new }} </ span >
{{ else if $file .Mode }}
< span class = "tw-mx-2 tw-font-mono tw-whitespace-nowrap" > {{ ctx .Locale.Tr ( $file .ModeTranslationKey $file .Mode ) }} </ span >
{{ end }}
< / span >
2023-07-06 17:33:04 +02:00
< / div >
2024-07-07 03:21:58 +00:00
< div class = "diff-file-header-actions tw-flex tw-items-center button-row tw-flex-wrap" >
2022-09-27 07:22:19 +02:00
{{ if $showFileViewToggle }}
2023-07-06 17:33:04 +02:00
< div class = "ui compact icon buttons" >
2023-09-25 10:56:50 +02:00
< button class = "ui tiny basic button file-view-toggle" data-toggle-selector = "#diff-source- {{ $file .NameHash }} " data-tooltip-content = " {{ ctx .Locale.Tr "repo.file_view_source" }} " > {{ svg "octicon-code" }} </ button >
< button class = "ui tiny basic button file-view-toggle active" data-toggle-selector = "#diff-rendered- {{ $file .NameHash }} " data-tooltip-content = " {{ ctx .Locale.Tr "repo.file_view_rendered" }} " > {{ svg "octicon-file" }} </ button >
2023-07-06 17:33:04 +02:00
< / div >
{{ end }}
{{ if $file .IsProtected }}
2023-09-25 10:56:50 +02:00
< span class = "ui basic label" > {{ ctx .Locale.Tr "repo.diff.protected" }} </ span >
2023-07-06 17:33:04 +02:00
{{ end }}
{{ if and $isReviewFile $file .HasChangedSinceLastReview }}
2023-09-25 10:56:50 +02:00
< span class = "changed-since-last-review unselectable not-mobile" > {{ ctx .Locale.Tr "repo.pulls.has_changed_since_last_review" }} </ span >
2023-07-06 17:33:04 +02:00
{{ end }}
{{ if not ( or $file .IsIncomplete $file .IsBin $file .IsSubmodule ) }}
2023-09-25 10:56:50 +02:00
< button class = "ui basic tiny button unescape-button not-mobile" > {{ ctx .Locale.Tr "repo.unescape_control_characters" }} </ button >
2024-03-24 19:23:38 +01:00
< button class = "ui basic tiny button escape-button tw-hidden" > {{ ctx .Locale.Tr "repo.escape_control_characters" }} </ button >
2023-07-06 17:33:04 +02:00
{{ end }}
{{ if and ( not $file .IsSubmodule ) ( not $.PageIsWiki ) }}
{{ if $file .IsDeleted }}
2023-09-25 10:56:50 +02:00
< a class = "ui basic tiny button" rel = "nofollow" href = " {{ $.BeforeSourcePath }} / {{ PathEscapeSegments .Name }} " > {{ ctx .Locale.Tr "repo.diff.view_file" }} </ a >
2023-07-06 17:33:04 +02:00
{{ else }}
2023-09-25 10:56:50 +02:00
< a class = "ui basic tiny button" rel = "nofollow" href = " {{ $.SourcePath }} / {{ PathEscapeSegments .Name }} " > {{ ctx .Locale.Tr "repo.diff.view_file" }} </ a >
2023-12-19 22:18:07 +01:00
{{ if and $.HeadBranchIsEditable ( not $file .IsLFSFile ) }}
< a class = "ui basic tiny button" rel = "nofollow" href = " {{ $.SourceRepoLink }} /_edit/ {{ PathEscapeSegments $.HeadBranch }} / {{ PathEscapeSegments .Name }} " > {{ ctx .Locale.Tr "repo.editor.edit_this_file" }} </ a >
{{ end }}
2023-07-06 17:33:04 +02:00
{{ end }}
{{ end }}
{{ if $isReviewFile }}
< label data-link = " {{ $.Issue.Link }} /viewed-files" data-headcommit = " {{ $.AfterCommitID }} " class = "viewed-file-form unselectable {{ if $file .IsViewed }} viewed-file-checked-form {{ end }} " >
2023-09-25 10:56:50 +02:00
< input type = "checkbox" name = " {{ $file .GetDiffFileName }} " autocomplete = "off" {{ if $file .IsViewed }} checked {{ end }} > {{ ctx .Locale.Tr "repo.pulls.has_viewed_file" }}
2023-07-06 17:33:04 +02:00
< / label >
{{ end }}
< / div >
< / h4 >
2023-07-28 21:18:12 +02:00
< div class = "diff-file-body ui attached unstackable table segment" {{ if and $file .IsViewed $.IsShowingAllCommits }} data-folded = "true" {{ end }} >
2024-03-24 19:23:38 +01:00
< 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 }} " >
2023-07-06 17:33:04 +02:00
{{ if or $file .IsIncomplete $file .IsBin }}
2024-03-23 21:11:15 +01:00
< div class = "diff-file-body binary" >
2023-07-06 17:33:04 +02:00
{{ if $file .IsIncomplete }}
{{ if $file .IsIncompleteLineTooLong }}
2023-09-25 10:56:50 +02:00
{{ ctx .Locale.Tr "repo.diff.file_suppressed_line_too_long" }}
2022-09-27 07:22:19 +02:00
{{ else }}
2023-09-25 10:56:50 +02:00
{{ ctx .Locale.Tr "repo.diff.file_suppressed" }}
2024-03-20 13:56:42 +08:00
< a class = "ui basic tiny button diff-load-button" data-href = "?file-only=true&files= {{ $file .Name }} &files= {{ $file .OldName }} " > {{ ctx .Locale.Tr "repo.diff.load" }} </ a >
2022-09-27 07:22:19 +02:00
{{ end }}
2023-07-06 17:33:04 +02:00
{{ else }}
2023-09-25 10:56:50 +02:00
{{ ctx .Locale.Tr "repo.diff.bin_not_shown" }}
2023-07-06 17:33:04 +02:00
{{ end }}
2022-09-27 07:22:19 +02:00
< / div >
2023-07-06 17:33:04 +02:00
{{ else }}
fix: when reviewing in PRs, make comments relative to viewed base & head, not just viewed head (#12107)
While developing tests for #12092, I came across a case where making a comment on a single-commit doesn't include the correct diff for the comment. This is because code comment placement occurs between the PR's base and the commit being viewed, but, that diff could be different from the commit's parent to the commit, which is what is being viewed on a single-commit diff.
Similar to #12055, this PR changes code comments to be more precise in their diff generation by providing the backend with both the base commit (`before_commit_id`) and head commit (`after_commit_id`) currently being viewed. As a result, the diffs attached to comments should exactly match the diffs being viewed by the user when the comment was placed.
## Checklist
The [contributor guide](https://forgejo.org/docs/next/contributor/) contains information that will be helpful to first time contributors. All work and communication must conform to Forgejo's [AI Agreement](https://codeberg.org/forgejo/governance/src/branch/main/AIAgreement.md). There also are a few [conditions for merging Pull Requests in Forgejo repositories](https://codeberg.org/forgejo/governance/src/branch/main/PullRequestsAgreement.md). You are also welcome to join the [Forgejo development chatroom](https://matrix.to/#/#forgejo-development:matrix.org).
### Tests for Go changes
- I added test coverage for Go changes...
- [ ] in their respective `*_test.go` for unit tests.
- [x] in the `tests/integration` directory if it involves interactions with a live Forgejo server.
- I ran...
- [x] `make pr-go` before pushing
### Documentation
- [ ] I created a pull request [to the documentation](https://codeberg.org/forgejo/docs) to explain to Forgejo users how to use this change.
- [x] I did not document these changes and I do not expect someone else to do it.
### Release notes
- [x] This change will be noticed by a Forgejo user or admin (feature, bug fix, performance, etc.). I suggest to include a release note for this change.
- [ ] This change is not visible to a Forgejo user or admin (refactor, dependency upgrade, etc.). I think there is no need to add a release note for this change.
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/12107
Reviewed-by: Andreas Ahlenstorf <aahlenst@noreply.codeberg.org>
Co-authored-by: Mathieu Fenniak <mathieu@fenniak.net>
Co-committed-by: Mathieu Fenniak <mathieu@fenniak.net>
2026-04-14 17:18:14 +02:00
< table class = "chroma" data-new-comment-url = " {{ $.Issue.Link }} /files/reviews/new_comment?before_commit_id= {{ $.BeforeCommitID }} &after_commit_id= {{ $.AfterCommitID }} " data-path = " {{ $file .Name }} " >
2023-07-06 17:33:04 +02:00
{{ if $.IsSplitStyle }}
{{ template "repo/diff/section_split" dict "file" . "root" $ }}
{{ else }}
{{ template "repo/diff/section_unified" dict "file" . "root" $ }}
{{ end }}
< / table >
2022-09-27 07:22:19 +02:00
{{ end }}
2020-10-31 23:15:11 +01:00
< / div >
2023-07-06 17:33:04 +02:00
{{ if $showFileViewToggle }}
{{/* for image or CSV, it can have a horizontal scroll bar, there won't be review comment context menu (position absolute) which would be clipped by "overflow" */}}
2024-03-04 04:33:20 +01:00
< div id = "diff-rendered- {{ $file .NameHash }} " class = "file-body file-code {{ if $.IsSplitStyle }} code-diff-split {{ else }} code-diff-unified {{ end }} tw-overflow-x-scroll" >
2024-02-27 22:31:41 +08:00
< table class = "chroma tw-w-full" >
2023-07-06 17:33:04 +02:00
{{ if $isImage }}
2023-10-11 14:34:21 +02:00
{{ template "repo/diff/image_diff" dict "file" . "root" $ "blobBase" $blobBase "blobHead" $blobHead "sniffedTypeBase" $sniffedTypeBase "sniffedTypeHead" $sniffedTypeHead }}
2023-07-06 17:33:04 +02:00
{{ else }}
2023-10-11 14:34:21 +02:00
{{ template "repo/diff/csv_diff" dict "file" . "root" $ "blobBase" $blobBase "blobHead" $blobHead "sniffedTypeBase" $sniffedTypeBase "sniffedTypeHead" $sniffedTypeHead }}
2023-07-06 17:33:04 +02:00
{{ end }}
< / table >
< / div >
{{ end }}
2022-09-27 07:22:19 +02:00
< / div >
2023-07-06 17:33:04 +02:00
< / div >
{{ end }}
2016-06-29 12:11:00 -03:00
2023-07-06 17:33:04 +02:00
{{ if .Diff.IsIncomplete }}
Migrate margin and padding helpers to tailwind (#30043)
This will conclude the refactor of 1:1 class replacements to tailwind,
except `gt-hidden`. Commands ran:
```bash
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-0#tw-$1$2-0#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-1#tw-$1$2-0.5#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-2#tw-$1$2-1#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-3#tw-$1$2-2#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-4#tw-$1$2-4#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-5#tw-$1$2-8#g' {web_src/js,templates,routers,services}/**/*
```
(cherry picked from commit 68ec9b48592fe88765bcc3a73093d43c98b315de)
Conflicts:
routers/web/repo/view.go
templates/base/head_navbar.tmpl
templates/repo/code/recently_pushed_new_branches.tmpl
templates/repo/diff/box.tmpl
templates/repo/diff/compare.tmpl
templates/repo/diff/conversation.tmpl
templates/repo/header.tmpl
templates/repo/issue/filter_list.tmpl
templates/repo/issue/view_content/conversation.tmpl
templates/repo/issue/view_content/sidebar.tmpl
templates/repo/settings/options.tmpl
templates/repo/view_file.tmpl
templates/shared/user/blocked_users.tmpl
templates/status/500.tmpl
web_src/js/components/DashboardRepoList.vue
resolved by prefering Forgejo version and applying the
commands to all files
2024-03-24 17:42:49 +01:00
< div class = "diff-file-box diff-box file-content tw-mt-2" id = "diff-incomplete" >
2024-03-24 14:32:19 +01:00
< h4 class = "ui top attached header tw-font-normal tw-flex tw-items-center tw-justify-between" >
2023-09-25 10:56:50 +02:00
{{ ctx .Locale.Tr "repo.diff.too_many_files" }}
2024-03-20 13:56:42 +08:00
< a class = "ui basic tiny button" id = "diff-show-more-files" data-href = "?skip-to= {{ .Diff.End }} &file-only=true" > {{ ctx .Locale.Tr "repo.diff.show_more" }} </ a >
2023-07-06 17:33:04 +02:00
< / h4 >
2019-10-21 09:51:24 +02:00
< / div >
2023-07-06 17:33:04 +02:00
{{ end }}
< / div >
2021-01-08 22:49:55 +01:00
{{ end }}
2025-06-17 09:31:50 +02:00
< / div >
2023-07-06 17:33:04 +02:00
< / div >
2018-08-06 07:43:22 +03:00
2023-07-06 17:33:04 +02:00
{{ if and ( not $.Repository.IsArchived ) ( not .DiffNotAvailable ) }}
< template id = "issue-comment-editor-template" >
< div class = "ui comment form" >
{{ template "shared/combomarkdowneditor" ( dict
"MarkdownPreviewUrl" (print $.Repository.Link "/markup")
"MarkdownPreviewContext" $.RepoLink
"TextareaName" "content"
"DropzoneParentContainer" ".ui.form"
)}}
2024-02-25 07:00:55 +01:00
{{ if .IsAttachmentEnabled }}
< div class = "field" >
{{ template "repo/upload" . }}
< / div >
{{ end }}
2023-07-06 17:33:04 +02:00
< div class = "text right edit buttons" >
2024-12-31 18:03:54 +01:00
< button class = "ui cancel button" data-button-name = "cancel-edit" > {{ ctx .Locale.Tr "repo.issues.cancel" }} </ button >
< button class = "ui primary save button" data-button-name = "save-edit" > {{ ctx .Locale.Tr "repo.issues.save" }} </ button >
2023-07-06 17:33:04 +02:00
< / div >
< / div >
< / template >
{{ end }}
{{ if ( not .DiffNotAvailable ) }}
2021-01-21 14:51:17 +01:00
{{ template "repo/issue/view_content/reference_issue_dialog" . }}
2023-07-06 17:33:04 +02:00
{{ end }}
< / div >