loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: Allow opening a single-file diff from file history view (#6599)

This PR adds a small icon link to the file history list to open the diff for *only* this file in the respective commit. This is very useful if the commit in question touches a very large amount of files and finding the actual file in the diff is tedious.

- fixes #6596

Co-authored-by: Gusted <postmaster@gusted.xyz>
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6599
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: Yann Büchau <nobodyinperson@posteo.de>
Co-committed-by: Yann Büchau <nobodyinperson@posteo.de>

authored by

Yann Büchau
Gusted
Yann Büchau
and committed by
Gusted
0d3a759f d1d78c1b

+13 -1
+1
options/locale/locale_en-US.ini
··· 1453 1453 commits.gpg_key_id = GPG key ID 1454 1454 commits.ssh_key_fingerprint = SSH key fingerprint 1455 1455 commits.view_path=View at this point in history 1456 + commits.view_single_diff = View changes to this file introduced in this commit 1456 1457 1457 1458 commit.operations = Operations 1458 1459 commit.revert = Revert
+8
templates/repo/commits_list.tmpl
··· 81 81 <td class="text right aligned tw-py-0"> 82 82 <button class="btn interact-bg tw-p-2" data-tooltip-content="{{ctx.Locale.Tr "copy_hash"}}" data-clipboard-text="{{.ID}}">{{svg "octicon-copy"}}</button> 83 83 {{if not $.PageIsWiki}} 84 + {{if $.FileName}} 85 + <a 86 + class="btn interact-bg tw-p-2" 87 + data-tooltip-content="{{ctx.Locale.Tr "repo.commits.view_single_diff"}}" 88 + href="{{printf "%s/commit/%s?files=%s" $commitRepoLink (PathEscape .ID.String) (PathEscapeSegments $.FileName)}}"> 89 + {{svg "octicon-file-diff"}} 90 + </a> 91 + {{end}} 84 92 <a 85 93 class="btn interact-bg tw-p-2" 86 94 data-tooltip-content="{{ctx.Locale.Tr "repo.commits.view_path"}}"
+4 -1
tests/integration/view_test.go
··· 131 131 }) 132 132 } 133 133 134 - func TestInHistoryButton(t *testing.T) { 134 + func TestCommitListActions(t *testing.T) { 135 135 onGiteaRun(t, func(t *testing.T, u *url.URL) { 136 136 user2 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}) 137 137 session := loginUser(t, user2.Name) ··· 164 164 htmlDoc.AssertElement(t, fmt.Sprintf(".commit-list a[href^='/%s/src/commit/']", repo.FullName()), false) 165 165 }) 166 166 167 + fileDiffSelector := fmt.Sprintf(".commit-list a[href='/%s/commit/%s?files=test.sh']", repo.FullName(), commitID) 167 168 t.Run("Commit list", func(t *testing.T) { 168 169 defer tests.PrintCurrentTest(t)() 169 170 ··· 172 173 htmlDoc := NewHTMLParser(t, resp.Body) 173 174 174 175 htmlDoc.AssertElement(t, fmt.Sprintf(".commit-list a[href='/%s/src/commit/%s']", repo.FullName(), commitID), true) 176 + htmlDoc.AssertElement(t, fileDiffSelector, false) 175 177 }) 176 178 177 179 t.Run("File history", func(t *testing.T) { ··· 182 184 htmlDoc := NewHTMLParser(t, resp.Body) 183 185 184 186 htmlDoc.AssertElement(t, fmt.Sprintf(".commit-list a[href='/%s/src/commit/%s/test.sh']", repo.FullName(), commitID), true) 187 + htmlDoc.AssertElement(t, fileDiffSelector, true) 185 188 }) 186 189 }) 187 190 }