]> git.scottworley.com Git - pinch/commitdiff
More tests around rejecting force pushes
authorScott Worley <scottworley@scottworley.com>
Sat, 23 May 2020 04:15:18 +0000 (21:15 -0700)
committerScott Worley <scottworley@scottworley.com>
Sat, 23 May 2020 04:25:14 +0000 (21:25 -0700)
tests/reject-amend.sh [new file with mode: 0755]
tests/reject-force-push.sh [new file with mode: 0755]
tests/reject-nonancestor.sh
tests/reject-nonancestor2.sh [new file with mode: 0755]

diff --git a/tests/reject-amend.sh b/tests/reject-amend.sh
new file mode 100755 (executable)
index 0000000..f8cc2e9
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+. ./tests/lib/test-setup.sh
+
+foo_setup
+
+python3 ./pinch.py pin "$conf"
+
+(
+  cd "$repo"
+  echo Other contents > other-file
+  git add other-file
+  git commit --amend -m 'Amended commit message'
+)
+
+if python3 ./pinch.py pin "$conf";then
+  echo "FAIL: non-ancestor commit should be rejected"
+  exit 1
+else
+  echo PASS
+fi
diff --git a/tests/reject-force-push.sh b/tests/reject-force-push.sh
new file mode 100755 (executable)
index 0000000..4a0614f
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+. ./tests/lib/test-setup.sh
+
+foo_setup
+conf_bak=$(mktemp)
+cp "$conf" "$conf_bak"
+
+python3 ./pinch.py pin "$conf"
+
+(
+  cd "$repo"
+  echo Other contents > other-file
+  git add other-file
+  git commit --amend -m 'Amended commit message'
+)
+
+mv "$conf_bak" "$conf"
+
+if python3 ./pinch.py pin "$conf";then
+  echo "FAIL: non-ancestor commit should be rejected"
+  exit 1
+else
+  echo PASS
+fi
+
index f8cc2e98694b7cc1afbd5ce0042d7ab8a5ab0676..44f2a82c1c32a66854d962b8e0fb6167e1bb7ab1 100755 (executable)
@@ -13,6 +13,8 @@ python3 ./pinch.py pin "$conf"
   git commit --amend -m 'Amended commit message'
 )
 
+rm -rf "$cache_dir"/*
+
 if python3 ./pinch.py pin "$conf";then
   echo "FAIL: non-ancestor commit should be rejected"
   exit 1
diff --git a/tests/reject-nonancestor2.sh b/tests/reject-nonancestor2.sh
new file mode 100755 (executable)
index 0000000..924d229
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+. ./tests/lib/test-setup.sh
+
+foo_setup
+
+(
+  cd "$repo"
+  git checkout -b historical
+  git checkout master
+  echo Other contents > other-file
+  git add other-file
+  git commit -m 'Second commit message'
+)
+
+python3 ./pinch.py pin "$conf"
+
+sed -i 's/master/historical/' "$conf"
+
+if python3 ./pinch.py pin "$conf";then
+  echo "FAIL: non-ancestor commit should be rejected"
+  exit 1
+else
+  echo PASS
+fi