Skip to content

Commit f40d075

Browse files
committed
Use the real link location of symlinked files
Only problem at the moment is that `git.TreeEntry` does not store the full path of the entry, only the actual filename without directory.
1 parent b0e6c25 commit f40d075

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

modules/git/tree_entry.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,16 @@ func (te *TreeEntry) FollowLinks() (*TreeEntry, error) {
101101
return entry, nil
102102
}
103103

104+
// TryFollowingLinks attempts to follow the symlinks of this entry to the origin
105+
// If that fails, it defaults to the entry itself
106+
func (te *TreeEntry) TryFollowingLinks() (*TreeEntry) {
107+
newEntry, err := te.FollowLinks()
108+
if err != nil {
109+
return te
110+
}
111+
return newEntry
112+
}
113+
104114
// returns the Tree pointed to by this TreeEntry, or nil if this is not a tree
105115
func (te *TreeEntry) Tree() *Tree {
106116
t, err := te.ptree.repo.getTree(te.ID)

templates/repo/view_list.tmpl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
{{if .LatestCommitUser}}
99
{{ctx.AvatarUtils.Avatar .LatestCommitUser 24 "gt-mr-2"}}
1010
{{if .LatestCommitUser.FullName}}
11-
<a class="muted author-wrapper" title="{{.LatestCommitUser.FullName}}" href="{{.LatestCommitUser.HomeLink}}"><strong>{{.LatestCommitUser.FullName}}</strong></a>
11+
<a class="muted author-wrapper" data-tooltip-content title="{{.LatestCommitUser.FullName}}" href="{{.LatestCommitUser.HomeLink}}"><strong>{{.LatestCommitUser.FullName}}</strong></a>
1212
{{else}}
13-
<a class="muted author-wrapper" title="{{if .LatestCommit.Author}}{{.LatestCommit.Author.Name}}{{else}}{{.LatestCommitUser.Name}}{{end}}" href="{{.LatestCommitUser.HomeLink}}"><strong>{{if .LatestCommit.Author}}{{.LatestCommit.Author.Name}}{{else}}{{.LatestCommitUser.Name}}{{end}}</strong></a>
13+
<a class="muted author-wrapper" data-tooltip-content title="{{if .LatestCommit.Author}}{{.LatestCommit.Author.Name}}{{else}}{{.LatestCommitUser.Name}}{{end}}" href="{{.LatestCommitUser.HomeLink}}"><strong>{{if .LatestCommit.Author}}{{.LatestCommit.Author.Name}}{{else}}{{.LatestCommitUser.Name}}{{end}}</strong></a>
1414
{{end}}
1515
{{else}}
1616
{{if .LatestCommit.Author}}
1717
{{ctx.AvatarUtils.AvatarByEmail .LatestCommit.Author.Email .LatestCommit.Author.Name 24 "gt-mr-2"}}
18-
<span class="author-wrapper" title="{{.LatestCommit.Author.Name}}"><strong>{{.LatestCommit.Author.Name}}</strong></span>
18+
<span class="author-wrapper" data-tooltip-content title="{{.LatestCommit.Author.Name}}"><strong>{{.LatestCommit.Author.Name}}</strong></span>
1919
{{end}}
2020
{{end}}
2121
<a rel="nofollow" class="ui sha label {{if .LatestCommit.Signature}} isSigned {{if .LatestCommitVerification.Verified}} isVerified{{if eq .LatestCommitVerification.TrustStatus "trusted"}}{{else if eq .LatestCommitVerification.TrustStatus "untrusted"}}Untrusted{{else}}Unmatched{{end}}{{else if .LatestCommitVerification.Warning}} isWarning{{end}}{{end}}" href="{{.RepoLink}}/commit/{{PathEscape .LatestCommit.ID.String}}">
@@ -26,7 +26,7 @@
2626
</a>
2727
{{template "repo/commit_statuses" dict "Status" .LatestCommitStatus "Statuses" .LatestCommitStatuses}}
2828
{{$commitLink:= printf "%s/commit/%s" .RepoLink (PathEscape .LatestCommit.ID.String)}}
29-
<span class="grey commit-summary" title="{{.LatestCommit.Summary}}"><span class="message-wrapper">{{RenderCommitMessageLinkSubject $.Context .LatestCommit.Message $commitLink ($.Repository.ComposeMetas ctx)}}</span>
29+
<span class="grey commit-summary" data-tooltip-content title="{{.LatestCommit.Summary}}"><span class="message-wrapper">{{RenderCommitMessageLinkSubject $.Context .LatestCommit.Message $commitLink ($.Repository.ComposeMetas ctx)}}</span>
3030
{{if IsMultilineCommitMessage .LatestCommit.Message}}
3131
<button class="ui button js-toggle-commit-body ellipsis-button" aria-expanded="false">...</button>
3232
<pre class="commit-body gt-hidden">{{RenderCommitBody $.Context .LatestCommit.Message ($.Repository.ComposeMetas ctx)}}</pre>
@@ -62,7 +62,7 @@
6262
{{if $entry.IsDir}}
6363
{{$subJumpablePathName := $entry.GetSubJumpablePathName}}
6464
{{svg "octicon-file-directory-fill"}}
65-
<a class="muted" href="{{$.TreeLink}}/{{PathEscapeSegments $subJumpablePathName}}" title="{{$subJumpablePathName}}">
65+
<a class="muted" href="{{$.TreeLink}}/{{PathEscapeSegments $subJumpablePathName}}" data-tooltip-content title="{{$subJumpablePathName}}">
6666
{{$subJumpablePathFields := StringUtils.Split $subJumpablePathName "/"}}
6767
{{$subJumpablePathFieldLast := (Eval (len $subJumpablePathFields) "-" 1)}}
6868
{{if eq $subJumpablePathFieldLast 0}}
@@ -74,7 +74,9 @@
7474
</a>
7575
{{else}}
7676
{{svg (printf "octicon-%s" (EntryIcon $entry))}}
77-
<a class="muted" href="{{$.TreeLink}}/{{PathEscapeSegments $entry.Name}}" title="{{$entry.Name}}">{{$entry.Name}}</a>
77+
{{$symLinkEntry := $entry}}
78+
{{if $entry.IsLink}}{{$symLinkEntry = $entry.TryFollowingLinks}}{{end}}
79+
<a class="muted" href="{{$.TreeLink}}/{{$symLinkEntry.Name}}" data-tooltip-content title="{{$entry.Name}}">{{$entry.Name}}</a>
7880
{{end}}
7981
{{end}}
8082
</span>

0 commit comments

Comments
 (0)