summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKyle D <kdumontnu@gmail.com>2023-02-20 04:56:07 +0100
committerGitHub <noreply@github.com>2023-02-20 04:56:07 +0100
commit2b3f12f6fd12afebb3b8397dc612621df6c730e2 (patch)
tree427e05fe61548413bac83ddde088f368e8f967e7 /tests
parentAdd comment marking the end of database migrations in `1.19.0` (#22975) (diff)
downloadforgejo-2b3f12f6fd12afebb3b8397dc612621df6c730e2.tar.xz
forgejo-2b3f12f6fd12afebb3b8397dc612621df6c730e2.zip
Use beforeCommit instead of baseCommit (#22949)
Replaces: https://github.com/go-gitea/gitea/pull/22947 Fixes https://github.com/go-gitea/gitea/issues/22946 Probably related to https://github.com/go-gitea/gitea/issues/19530 Basically, many of the diffs were broken because they were comparing to the base commit, where a 3-dot diff should be comparing to the [last common ancestor](https://matthew-brett.github.io/pydagogue/git_diff_dots.html). This should have an integration test so that we don’t run into this issue again. --------- Co-authored-by: Jonathan Tran <jonnytran@gmail.com>
Diffstat (limited to 'tests')
-rwxr-xr-xtests/gitea-repositories-meta/user2/repo20.git/hooks/post-receive.d/gitea2
-rwxr-xr-xtests/gitea-repositories-meta/user2/repo20.git/hooks/pre-receive.d/gitea2
-rwxr-xr-xtests/gitea-repositories-meta/user2/repo20.git/hooks/update.d/gitea2
-rw-r--r--tests/gitea-repositories-meta/user2/repo20.git/objects/07/0b2e783a6b3e521a23fdead377a3e41a04410dbin0 -> 128 bytes
-rw-r--r--tests/gitea-repositories-meta/user2/repo20.git/objects/79/adb592126eddce5f656f56db797910db025af0bin0 -> 165 bytes
-rw-r--r--tests/gitea-repositories-meta/user2/repo20.git/objects/8b/abce967f21b9dfa6987f943b91093dac58a4f01
-rw-r--r--tests/gitea-repositories-meta/user2/repo20.git/objects/a4/202876cd8bbc3f38b7d99594edbe1bb7f97a6fbin0 -> 191 bytes
-rw-r--r--tests/gitea-repositories-meta/user2/repo20.git/objects/b0/246d5964a3630491bd06c756be46513e3d7035bin0 -> 21 bytes
-rw-r--r--tests/gitea-repositories-meta/user2/repo20.git/objects/b6/7e43a07d48243a5f670ace063acd5e13f719dfbin0 -> 173 bytes
-rw-r--r--tests/gitea-repositories-meta/user2/repo20.git/objects/c8/e31bc7688741a5287fcde4fbb8fc129ca070272
-rw-r--r--tests/gitea-repositories-meta/user2/repo20.git/objects/cf/e3b3c1fd36fba04f9183287b106497e1afe9863
-rw-r--r--tests/gitea-repositories-meta/user2/repo20.git/objects/ea/f5f7510320b6a327fb308379de2f94d8859a54bin0 -> 30 bytes
-rw-r--r--tests/gitea-repositories-meta/user2/repo20.git/refs/heads/add-csv1
-rw-r--r--tests/gitea-repositories-meta/user2/repo20.git/refs/heads/remove-files-a1
-rw-r--r--tests/gitea-repositories-meta/user2/repo20.git/refs/heads/remove-files-b1
-rw-r--r--tests/integration/compare_test.go78
16 files changed, 90 insertions, 3 deletions
diff --git a/tests/gitea-repositories-meta/user2/repo20.git/hooks/post-receive.d/gitea b/tests/gitea-repositories-meta/user2/repo20.git/hooks/post-receive.d/gitea
index ee2ab2f2df..43a948da3a 100755
--- a/tests/gitea-repositories-meta/user2/repo20.git/hooks/post-receive.d/gitea
+++ b/tests/gitea-repositories-meta/user2/repo20.git/hooks/post-receive.d/gitea
@@ -1,2 +1,2 @@
#!/usr/bin/env bash
-"/home/tris/Projects/go/src/code.gitea.io/gitea/gitea" hook --config='/home/tris/Projects/go/src/code.gitea.io/gitea/custom/conf/app.ini' post-receive
+"$GITEA_ROOT/gitea" hook --config="$GITEA_ROOT/$GITEA_CONF" post-receive
diff --git a/tests/gitea-repositories-meta/user2/repo20.git/hooks/pre-receive.d/gitea b/tests/gitea-repositories-meta/user2/repo20.git/hooks/pre-receive.d/gitea
index cdbc3c7c1a..49d0940636 100755
--- a/tests/gitea-repositories-meta/user2/repo20.git/hooks/pre-receive.d/gitea
+++ b/tests/gitea-repositories-meta/user2/repo20.git/hooks/pre-receive.d/gitea
@@ -1,2 +1,2 @@
#!/usr/bin/env bash
-"/home/tris/Projects/go/src/code.gitea.io/gitea/gitea" hook --config='/home/tris/Projects/go/src/code.gitea.io/gitea/custom/conf/app.ini' pre-receive
+"$GITEA_ROOT/gitea" hook --config="$GITEA_ROOT/$GITEA_CONF" pre-receive
diff --git a/tests/gitea-repositories-meta/user2/repo20.git/hooks/update.d/gitea b/tests/gitea-repositories-meta/user2/repo20.git/hooks/update.d/gitea
index 7447b2fe01..38101c2426 100755
--- a/tests/gitea-repositories-meta/user2/repo20.git/hooks/update.d/gitea
+++ b/tests/gitea-repositories-meta/user2/repo20.git/hooks/update.d/gitea
@@ -1,2 +1,2 @@
#!/usr/bin/env bash
-"/home/tris/Projects/go/src/code.gitea.io/gitea/gitea" hook --config='/home/tris/Projects/go/src/code.gitea.io/gitea/custom/conf/app.ini' update $1 $2 $3
+"$GITEA_ROOT/gitea" hook --config="$GITEA_ROOT/$GITEA_CONF" update $1 $2 $3
diff --git a/tests/gitea-repositories-meta/user2/repo20.git/objects/07/0b2e783a6b3e521a23fdead377a3e41a04410d b/tests/gitea-repositories-meta/user2/repo20.git/objects/07/0b2e783a6b3e521a23fdead377a3e41a04410d
new file mode 100644
index 0000000000..7ec6df17fb
--- /dev/null
+++ b/tests/gitea-repositories-meta/user2/repo20.git/objects/07/0b2e783a6b3e521a23fdead377a3e41a04410d
Binary files differ
diff --git a/tests/gitea-repositories-meta/user2/repo20.git/objects/79/adb592126eddce5f656f56db797910db025af0 b/tests/gitea-repositories-meta/user2/repo20.git/objects/79/adb592126eddce5f656f56db797910db025af0
new file mode 100644
index 0000000000..0071ac75b4
--- /dev/null
+++ b/tests/gitea-repositories-meta/user2/repo20.git/objects/79/adb592126eddce5f656f56db797910db025af0
Binary files differ
diff --git a/tests/gitea-repositories-meta/user2/repo20.git/objects/8b/abce967f21b9dfa6987f943b91093dac58a4f0 b/tests/gitea-repositories-meta/user2/repo20.git/objects/8b/abce967f21b9dfa6987f943b91093dac58a4f0
new file mode 100644
index 0000000000..06bf6dc972
--- /dev/null
+++ b/tests/gitea-repositories-meta/user2/repo20.git/objects/8b/abce967f21b9dfa6987f943b91093dac58a4f0
@@ -0,0 +1 @@
+xAn0 s+l [_ATkIJC>z[,f1Z!K̀SL5[,D҉':aRнeDl :^CglHd>iqrms1Km=?U3okߝ{@wʼE] \ No newline at end of file
diff --git a/tests/gitea-repositories-meta/user2/repo20.git/objects/a4/202876cd8bbc3f38b7d99594edbe1bb7f97a6f b/tests/gitea-repositories-meta/user2/repo20.git/objects/a4/202876cd8bbc3f38b7d99594edbe1bb7f97a6f
new file mode 100644
index 0000000000..5096e42a23
--- /dev/null
+++ b/tests/gitea-repositories-meta/user2/repo20.git/objects/a4/202876cd8bbc3f38b7d99594edbe1bb7f97a6f
Binary files differ
diff --git a/tests/gitea-repositories-meta/user2/repo20.git/objects/b0/246d5964a3630491bd06c756be46513e3d7035 b/tests/gitea-repositories-meta/user2/repo20.git/objects/b0/246d5964a3630491bd06c756be46513e3d7035
new file mode 100644
index 0000000000..88d468ea23
--- /dev/null
+++ b/tests/gitea-repositories-meta/user2/repo20.git/objects/b0/246d5964a3630491bd06c756be46513e3d7035
Binary files differ
diff --git a/tests/gitea-repositories-meta/user2/repo20.git/objects/b6/7e43a07d48243a5f670ace063acd5e13f719df b/tests/gitea-repositories-meta/user2/repo20.git/objects/b6/7e43a07d48243a5f670ace063acd5e13f719df
new file mode 100644
index 0000000000..794a74a97c
--- /dev/null
+++ b/tests/gitea-repositories-meta/user2/repo20.git/objects/b6/7e43a07d48243a5f670ace063acd5e13f719df
Binary files differ
diff --git a/tests/gitea-repositories-meta/user2/repo20.git/objects/c8/e31bc7688741a5287fcde4fbb8fc129ca07027 b/tests/gitea-repositories-meta/user2/repo20.git/objects/c8/e31bc7688741a5287fcde4fbb8fc129ca07027
new file mode 100644
index 0000000000..48bb1a43d9
--- /dev/null
+++ b/tests/gitea-repositories-meta/user2/repo20.git/objects/c8/e31bc7688741a5287fcde4fbb8fc129ca07027
@@ -0,0 +1,2 @@
+xA
+0@Q9\@N&w"L4Ҧ+Z؀vm`!&u֎mFKla8t]l;H}g9'2}{*lQ}&+i+unv0NX ,!{D&:uI <NqEo \ No newline at end of file
diff --git a/tests/gitea-repositories-meta/user2/repo20.git/objects/cf/e3b3c1fd36fba04f9183287b106497e1afe986 b/tests/gitea-repositories-meta/user2/repo20.git/objects/cf/e3b3c1fd36fba04f9183287b106497e1afe986
new file mode 100644
index 0000000000..ed40dd00e9
--- /dev/null
+++ b/tests/gitea-repositories-meta/user2/repo20.git/objects/cf/e3b3c1fd36fba04f9183287b106497e1afe986
@@ -0,0 +1,3 @@
+xAn0EYs=v2FB v=D5';UT
+Z묀%P(zpD%8!8[/orR1FpHS.3$]Egڴ{y9~{ vSgn
+_2c6tuI \ No newline at end of file
diff --git a/tests/gitea-repositories-meta/user2/repo20.git/objects/ea/f5f7510320b6a327fb308379de2f94d8859a54 b/tests/gitea-repositories-meta/user2/repo20.git/objects/ea/f5f7510320b6a327fb308379de2f94d8859a54
new file mode 100644
index 0000000000..5302511266
--- /dev/null
+++ b/tests/gitea-repositories-meta/user2/repo20.git/objects/ea/f5f7510320b6a327fb308379de2f94d8859a54
Binary files differ
diff --git a/tests/gitea-repositories-meta/user2/repo20.git/refs/heads/add-csv b/tests/gitea-repositories-meta/user2/repo20.git/refs/heads/add-csv
new file mode 100644
index 0000000000..c95a517668
--- /dev/null
+++ b/tests/gitea-repositories-meta/user2/repo20.git/refs/heads/add-csv
@@ -0,0 +1 @@
+c8e31bc7688741a5287fcde4fbb8fc129ca07027
diff --git a/tests/gitea-repositories-meta/user2/repo20.git/refs/heads/remove-files-a b/tests/gitea-repositories-meta/user2/repo20.git/refs/heads/remove-files-a
new file mode 100644
index 0000000000..138f2f43d5
--- /dev/null
+++ b/tests/gitea-repositories-meta/user2/repo20.git/refs/heads/remove-files-a
@@ -0,0 +1 @@
+cfe3b3c1fd36fba04f9183287b106497e1afe986
diff --git a/tests/gitea-repositories-meta/user2/repo20.git/refs/heads/remove-files-b b/tests/gitea-repositories-meta/user2/repo20.git/refs/heads/remove-files-b
new file mode 100644
index 0000000000..04270e29bd
--- /dev/null
+++ b/tests/gitea-repositories-meta/user2/repo20.git/refs/heads/remove-files-b
@@ -0,0 +1 @@
+8babce967f21b9dfa6987f943b91093dac58a4f0
diff --git a/tests/integration/compare_test.go b/tests/integration/compare_test.go
index dc2bff89fd..509524ca56 100644
--- a/tests/integration/compare_test.go
+++ b/tests/integration/compare_test.go
@@ -4,6 +4,7 @@
package integration
import (
+ "fmt"
"net/http"
"strings"
"testing"
@@ -40,3 +41,80 @@ func TestCompareDefault(t *testing.T) {
selection := htmlDoc.doc.Find(".choose.branch .filter.dropdown")
assert.Lenf(t, selection.Nodes, 2, "The template has changed")
}
+
+// Ensure the comparison matches what we expect
+func inspectCompare(t *testing.T, htmlDoc *HTMLDoc, diffCount int, diffChanges []string) {
+ selection := htmlDoc.doc.Find("#diff-file-boxes").Children()
+
+ assert.Lenf(t, selection.Nodes, diffCount, "Expected %v diffed files, found: %v", diffCount, len(selection.Nodes))
+
+ for _, diffChange := range diffChanges {
+ selection = htmlDoc.doc.Find(fmt.Sprintf("[data-new-filename=\"%s\"]", diffChange))
+ assert.Lenf(t, selection.Nodes, 1, "Expected 1 match for [data-new-filename=\"%s\"], found: %v", diffChange, len(selection.Nodes))
+ }
+}
+
+// Git commit graph for repo20
+// * 8babce9 (origin/remove-files-b) Add a dummy file
+// * b67e43a Delete test.csv and link_hi
+// | * cfe3b3c (origin/remove-files-a) Delete test.csv and link_hi
+// |/
+// * c8e31bc (origin/add-csv) Add test csv file
+// * 808038d (HEAD -> master, origin/master, origin/HEAD) Added test links
+
+func TestCompareBranches(t *testing.T) {
+ defer tests.PrepareTestEnv(t)()
+
+ session := loginUser(t, "user2")
+
+ // Inderect compare remove-files-b (head) with add-csv (base) branch
+ //
+ // 'link_hi' and 'test.csv' are deleted, 'test.txt' is added
+ req := NewRequest(t, "GET", "/user2/repo20/compare/add-csv...remove-files-b")
+ resp := session.MakeRequest(t, req, http.StatusOK)
+ htmlDoc := NewHTMLParser(t, resp.Body)
+
+ diffCount := 3
+ diffChanges := []string{"link_hi", "test.csv", "test.txt"}
+
+ inspectCompare(t, htmlDoc, diffCount, diffChanges)
+
+ // Inderect compare remove-files-b (head) with remove-files-a (base) branch
+ //
+ // 'link_hi' and 'test.csv' are deleted, 'test.txt' is added
+
+ req = NewRequest(t, "GET", "/user2/repo20/compare/remove-files-a...remove-files-b")
+ resp = session.MakeRequest(t, req, http.StatusOK)
+ htmlDoc = NewHTMLParser(t, resp.Body)
+
+ diffCount = 3
+ diffChanges = []string{"link_hi", "test.csv", "test.txt"}
+
+ inspectCompare(t, htmlDoc, diffCount, diffChanges)
+
+ // Inderect compare remove-files-a (head) with remove-files-b (base) branch
+ //
+ // 'link_hi' and 'test.csv' are deleted
+
+ req = NewRequest(t, "GET", "/user2/repo20/compare/remove-files-b...remove-files-a")
+ resp = session.MakeRequest(t, req, http.StatusOK)
+ htmlDoc = NewHTMLParser(t, resp.Body)
+
+ diffCount = 2
+ diffChanges = []string{"link_hi", "test.csv"}
+
+ inspectCompare(t, htmlDoc, diffCount, diffChanges)
+
+ // Direct compare remove-files-b (head) with remove-files-a (base) branch
+ //
+ // 'test.txt' is deleted
+
+ req = NewRequest(t, "GET", "/user2/repo20/compare/remove-files-b..remove-files-a")
+ resp = session.MakeRequest(t, req, http.StatusOK)
+ htmlDoc = NewHTMLParser(t, resp.Body)
+
+ diffCount = 1
+ diffChanges = []string{"test.txt"}
+
+ inspectCompare(t, htmlDoc, diffCount, diffChanges)
+}