aboutsummaryrefslogtreecommitdiff
path: root/tests
diff refs
from:
to:
flip
diff options
context:
space:
mode:
authorGravatar Saya Andy <saya.andy@posteo.com> 2026-09-07 20:26:15 +0700
committerGravatar Saya Andy <saya.andy@posteo.com> 2026-09-07 20:26:15 +0700
commit3b18a7d8c9608ed0bf13d546018f44e703c62e11 (patch)
treec2d89916720640350cc2efe4db0f6e66838d8465 /tests
parent8f95dce3ece6eccf240ed0b994fb267bf390bf30 (diff)
downloadcgitext-3b18a7d8c9608ed0bf13d546018f44e703c62e11.tar.gz
cgitext-3b18a7d8c9608ed0bf13d546018f44e703c62e11.zip
diff: add a flip link to the refs panelHEADv1.3.1+15masterdevelop
The from and to refs of a diff can only be swapped by editing the url by hand. Add a flip link to the refs panel that opens the same diff with the refs swapped, carrying the current head and options.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/t0106-diff.sh21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/t0106-diff.sh b/tests/t0106-diff.sh
index e4751e9..1100596 100755
--- a/tests/t0106-diff.sh
+++ b/tests/t0106-diff.sh
@@ -45,6 +45,15 @@ test_expect_success 'ref picker: auto-submit on change' '
grep "onchange=.this.form.submit()." tmp
'
+test_expect_success 'flip link present' '
+ grep "<a title=.swap from and to. class=.button. href=./foo/diff/?" tmp
+'
+
+test_expect_success 'flip link swaps the default refs' '
+ old=$(git --git-dir="$PWD/repos/foo/.git" rev-parse master~1) &&
+ grep "/foo/diff/?id=$old&amp;id2=master" tmp
+'
+
test_expect_success 'compare two refs: foo/diff?id=master&id2=HEAD' '
cgit_query "url=foo/diff&id=master&id2=HEAD" >tmp
'
@@ -77,4 +86,16 @@ test_expect_success 'diff with HEAD and root shows content' '
grep "diffstat" tmp
'
+test_expect_success 'flip link swaps explicit refs' '
+ cgit_query "url=foo/diff&id=master&id2=HEAD" >tmp &&
+ new=$(git --git-dir="$PWD/repos/foo/.git" rev-parse HEAD) &&
+ grep "/foo/diff/?id=$new&amp;id2=master" tmp
+'
+
+test_expect_success 'flip link omits id for a diff against a root commit' '
+ root=$(git --git-dir="$PWD/repos/foo/.git" rev-list --max-parents=0 HEAD) &&
+ cgit_query "url=foo/diff&id=$root" >tmp &&
+ grep "href=./foo/diff/?id2=$root." tmp
+'
+
test_done