File tree Expand file tree Collapse file tree 3 files changed +13
-0
lines changed
Expand file tree Collapse file tree 3 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -106,6 +106,7 @@ copy_hash = Copy hash
106106copy_content = Copy content
107107copy_branch = Copy branch name
108108copy_path = Copy path
109+ copy_name = Copy name
109110copy_success = Copied!
110111copy_error = Copy failed
111112copy_type_unsupported = This file type cannot be copied
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import (
1313 "html/template"
1414 "io"
1515 "net/url"
16+ "path/filepath"
1617 "sort"
1718 "strings"
1819 "time"
@@ -312,6 +313,7 @@ type DiffFile struct {
312313
313314 // basic fields (parsed from diff result)
314315 Name string
316+ ShortName string
315317 NameHash string
316318 OldName string
317319 Addition int
@@ -401,6 +403,14 @@ func (diffFile *DiffFile) GetDiffFileName() string {
401403 return diffFile .Name
402404}
403405
406+ // GetDiffFileName returns the short name of the diff file, or its short old name in case it was deleted
407+ func (diffFile * DiffFile ) GetDiffFileShortName () string {
408+ if diffFile .Name == "" {
409+ return filepath .Base (diffFile .OldName )
410+ }
411+ return filepath .Base (diffFile .Name )
412+ }
413+
404414func (diffFile * DiffFile ) ShouldBeHidden () bool {
405415 return diffFile .IsGenerated || diffFile .IsViewed
406416}
@@ -1027,6 +1037,7 @@ func createDiffFile(line string) *DiffFile {
10271037
10281038 curFile .OldName , oldNameAmbiguity = readFileName (rd )
10291039 curFile .Name , newNameAmbiguity = readFileName (rd )
1040+ curFile .ShortName = curFile .GetDiffFileShortName ()
10301041 if oldNameAmbiguity && newNameAmbiguity {
10311042 curFile .isAmbiguous = true
10321043 // OK we should bet that the oldName and the newName are the same if they can be made to be same
Original file line number Diff line number Diff line change 102102 </div>
103103 <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>
104104 <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>
105+ <button class="btn interact-fg tw-p-2" data-clipboard-text="{{$file.ShortName}}" data-tooltip-content="{{ctx.Locale.Tr "copy_name"}}">{{svg "octicon-file" 14}}</button>
105106 {{if .IsLFSFile}}<span class="ui label">LFS</span>{{end}}
106107 {{if $file.IsGenerated}}
107108 <span class="ui label">{{ctx.Locale.Tr "repo.diff.generated"}}</span>
You can’t perform that action at this time.
0 commit comments