aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAdam Spiers <git@adamspiers.org>2018-05-17 13:58:35 +0100
committerAdam Spiers <git@adamspiers.org>2018-05-17 14:11:07 +0100
commitd5ac51414eddd152bb9ded750cbbf99c45709337 (patch)
tree028fd4e08b791edb78f20ea7446384d4e443642c /tests
parent90905490a86248c4e9e5963f072ac7e3fd033411 (diff)
downloadgit-deps-d5ac51414eddd152bb9ded750cbbf99c45709337.tar.gz
create-repo.sh: start moving code into functions
Diffstat (limited to 'tests')
-rwxr-xr-xtests/create-repo.sh79
1 files changed, 42 insertions, 37 deletions
diff --git a/tests/create-repo.sh b/tests/create-repo.sh
index bfaffe2..029161c 100755
--- a/tests/create-repo.sh
+++ b/tests/create-repo.sh
@@ -1,26 +1,10 @@
#!/bin/bash
here=$(dirname $0)
-
-tag () {
- git tag "$@"
- echo -n "Hit Enter to continue ..."
- read
-}
-
test_repo=$here/test-repo
-rm -rf $test_repo
-mkdir $test_repo
-cd $test_repo
-
-git init
-git config user.email git-deps-test@fake.address
-
-# Start with two independently committed files
-
-for f in file-{a,b}; do
- cat <<EOF > $f
+new_file () {
+ cat <<EOF > $1
one
two
three
@@ -33,28 +17,49 @@ nine
ten
EOF
- git add $f
- git commit -m "create $f"
- tag $f
-done
+ git add $1
+ git commit -m "create $1"
+ tag $1
+}
-# Now start making changes
+tag () {
+ git tag "$@"
+ echo -n "Hit Enter to continue ..."
+ read
+}
-sed -i 's/three/three a/' file-a
-git commit -am 'file-a: change three to three a'
-tag file-a-three-a # depends on file-a
+main () {
+ rm -rf $test_repo
+ mkdir $test_repo
+ cd $test_repo
-sed -i 's/three/three a/' file-b
-git commit -am 'file-b: change three to three a'
-tag file-b-three-a # depends on file-b
+ git init
+ git config user.email git-deps-test@fake.address
-# Change non-overlapping part of previously changed file
-sed -i 's/eight/eight a/' file-a
-git commit -am 'file-a: change eight to eight a'
-tag file-a-eight-a # depends on file-a
+ # Start with two independently committed files
+ for f in file-{a,b}; do
+ new_file $f
+ done
-# Change previously changed line
-sed -i 's/three a/three b/' file-a
-git commit -am 'file-a: change three a to three b'
-tag file-a-three-b # depends on file-a-three-a
+ # Now start making changes
+
+ sed -i 's/three/three a/' file-a
+ git commit -am 'file-a: change three to three a'
+ tag file-a-three-a # depends on file-a
+
+ sed -i 's/three/three a/' file-b
+ git commit -am 'file-b: change three to three a'
+ tag file-b-three-a # depends on file-b
+
+ # Change non-overlapping part of previously changed file
+ sed -i 's/eight/eight a/' file-a
+ git commit -am 'file-a: change eight to eight a'
+ tag file-a-eight-a # depends on file-a
+
+ # Change previously changed line
+ sed -i 's/three a/three b/' file-a
+ git commit -am 'file-a: change three a to three b'
+ tag file-a-three-b # depends on file-a-three-a
+}
+main