Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ copy_path = Copy path
copy_success = Copied!
copy_error = Copy failed
copy_type_unsupported = This file type cannot be copied
copy_filename = Copy filename

write = Write
preview = Preview
Expand Down
9 changes: 9 additions & 0 deletions services/gitdiff/gitdiff.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"html/template"
"io"
"net/url"
"path"
"sort"
"strings"
"time"
Expand Down Expand Up @@ -401,6 +402,14 @@ func (diffFile *DiffFile) GetDiffFileName() string {
return diffFile.Name
}

// GetDiffFileName returns the short name of the diff file, or its short old name in case it was deleted
func (diffFile *DiffFile) GetDiffFileShortName() string {
if diffFile.Name == "" {
return path.Base(diffFile.OldName)
}
return path.Base(diffFile.Name)
}

func (diffFile *DiffFile) ShouldBeHidden() bool {
return diffFile.IsGenerated || diffFile.IsViewed
}
Expand Down
1 change: 1 addition & 0 deletions templates/repo/diff/box.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
<button class="unescape-button item" data-unicode-content-selector="#diff-{{$file.NameHash}}">{{ctx.Locale.Tr "repo.unescape_control_characters"}}</button>
<button class="escape-button tw-hidden item" data-unicode-content-selector="#diff-{{$file.NameHash}}">{{ctx.Locale.Tr "repo.escape_control_characters"}}</button>
{{end}}
<button class="copy-filename-button item" data-clipboard-text="{{$file.GetDiffFileShortName}}">{{ctx.Locale.Tr "copy_filename"}}</button>
{{if not $.PageIsWiki}}
{{if $file.IsDeleted}}
<a class="item" rel="nofollow" href="{{$.BeforeSourcePath}}/{{PathEscapeSegments .Name}}">{{ctx.Locale.Tr "repo.diff.view_file"}}</a>
Expand Down