Test the format version upgrade code
authorKarl Hasselström <kha@treskal.com>
Mon, 21 May 2007 20:58:38 +0000 (21:58 +0100)
committerCatalin Marinas <catalin.marinas@gmail.com>
Mon, 21 May 2007 20:59:29 +0000 (21:59 +0100)
This test contains tarballs of repositories created with older
versions of StGIT. It also contains the script used to generate them,
but at some point we will lose the ability to easily run old versions
-- for example, if git changes incompatibly -- so tarballs will be the
only practical option for sufficiently old versions.

Signed-off-by: Karl Hasselström <kha@treskal.com>
t/t4000-upgrade.sh [new file with mode: 0755]
t/t4000-upgrade/.gitignore [new file with mode: 0644]
t/t4000-upgrade/0.12.tar.gz [new file with mode: 0644]
t/t4000-upgrade/0.8.tar.gz [new file with mode: 0644]
t/t4000-upgrade/make-repo.sh [new file with mode: 0644]

diff --git a/t/t4000-upgrade.sh b/t/t4000-upgrade.sh
new file mode 100755 (executable)
index 0000000..8a308fb
--- /dev/null
@@ -0,0 +1,40 @@
+#!/bin/sh
+#
+# Copyright (c) 2007 Karl Hasselström
+#
+
+test_description='Make sure that we can use old StGIT repositories'
+
+. ./test-lib.sh
+
+for ver in 0.12 0.8; do
+
+    tar zxf ../t4000-upgrade/$ver.tar.gz
+    cd $ver
+
+    test_expect_success \
+        "v$ver: Check the list of applied and unapplied patches" '
+        [ "$(echo $(stg applied))" = "p0 p1 p2" ] &&
+        [ "$(echo $(stg unapplied))" = "p3 p4" ]
+    '
+
+    test_expect_success \
+        "v$ver: Make sure the 'description' file is no longer there" '
+        [ ! -e .git/patches/master/description ] &&
+        [ "$(echo $(git config branch.master.description))" = "cool branch" ]
+    '
+
+    test_expect_success \
+        "v$ver: Make sure the 'current' file is no longer there" '
+        [ ! -e .git/patches/master/current ]
+    '
+
+    test_expect_success \
+        "v$ver: Make sure the base ref is no longer there" '
+        ! git show-ref --verify --quiet refs/bases/master
+    '
+
+    cd ..
+done
+
+test_done
diff --git a/t/t4000-upgrade/.gitignore b/t/t4000-upgrade/.gitignore
new file mode 100644 (file)
index 0000000..d412eb6
--- /dev/null
@@ -0,0 +1,4 @@
+/stgit-0.8
+/stgit-0.12
+/0.8
+/0.12
diff --git a/t/t4000-upgrade/0.12.tar.gz b/t/t4000-upgrade/0.12.tar.gz
new file mode 100644 (file)
index 0000000..b183fcb
Binary files /dev/null and b/t/t4000-upgrade/0.12.tar.gz differ
diff --git a/t/t4000-upgrade/0.8.tar.gz b/t/t4000-upgrade/0.8.tar.gz
new file mode 100644 (file)
index 0000000..7a7d3c2
Binary files /dev/null and b/t/t4000-upgrade/0.8.tar.gz differ
diff --git a/t/t4000-upgrade/make-repo.sh b/t/t4000-upgrade/make-repo.sh
new file mode 100644 (file)
index 0000000..98b5020
--- /dev/null
@@ -0,0 +1,71 @@
+# This script makes several versions of a small test repository that
+# can be used for testing the format version upgrade code.
+
+LANG=C
+LC_ALL=C
+PAGER=cat
+TZ=UTC
+export LANG LC_ALL PAGER TZ
+unset AUTHOR_DATE
+unset AUTHOR_EMAIL
+unset AUTHOR_NAME
+unset COMMIT_AUTHOR_EMAIL
+unset COMMIT_AUTHOR_NAME
+unset GIT_ALTERNATE_OBJECT_DIRECTORIES
+unset GIT_AUTHOR_DATE
+GIT_AUTHOR_EMAIL=author@example.com
+GIT_AUTHOR_NAME='A U Thor'
+unset GIT_COMMITTER_DATE
+GIT_COMMITTER_EMAIL=committer@example.com
+GIT_COMMITTER_NAME='C O Mitter'
+unset GIT_DIFF_OPTS
+unset GIT_DIR
+unset GIT_EXTERNAL_DIFF
+unset GIT_INDEX_FILE
+unset GIT_OBJECT_DIRECTORY
+unset SHA1_FILE_DIRECTORIES
+unset SHA1_FILE_DIRECTORY
+export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME
+export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME
+
+for ver in 0.12 0.8; do
+    if [ -e $ver.tar.gz ]; then continue; fi
+
+    # Get the required stgit version.
+    (
+        cd ../..
+        git archive --format=tar --prefix=stgit-$ver/ v$ver
+    ) | tar xf -
+
+    # Set up a repository.
+    mkdir $ver
+    cd $ver
+    git init
+    touch foo
+    git add foo
+    git commit -m 'Initial commit'
+
+    # Use the old stgit.
+    (
+        pwd
+        PATH=../stgit-$ver:$PATH
+
+        stg --version
+        stg init
+        echo 'cool branch' > .git/patches/master/description
+
+        for i in 0 1 2 3 4; do
+            stg new p$i -m "Patch $i"
+            echo "Line $i" >> foo
+            stg refresh
+        done
+        stg pop -n 2
+    )
+
+    # Reduce the number of small files.
+    git gc
+
+    # Make a tarball.
+    cd ..
+    tar zcf $ver.tar.gz $ver
+done