summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2013-10-06 22:59:54 +0100
committerLars Wirzenius <liw@liw.fi>2013-10-06 22:59:54 +0100
commitdcf6766865deb36c6ae06e2696639762751e427a (patch)
treeab31d58a42483d88e0616b8592378b67f8c969c8
parent4c63ca3cd8ce471ec418d449397ac15454b363c5 (diff)
downloadliw-gitano-acl-test-suite-dcf6766865deb36c6ae06e2696639762751e427a.tar.gz
Refactor code to reduce duplication
-rw-r--r--git.liw.fi.sh28
1 files changed, 16 insertions, 12 deletions
diff --git a/git.liw.fi.sh b/git.liw.fi.sh
index 1c52c2e..9f03ff3 100644
--- a/git.liw.fi.sh
+++ b/git.liw.fi.sh
@@ -66,14 +66,17 @@ user_add()
}
-# Remove a user from the server. This is a two-step process.
+# A helper function to do a two-step destruction on gitano. With the
+# first step, gitano outputs a token, which is the last word on the
+# last line of the output. The second step has the same command line
+# as the first step, but with the token appended.
-user_del()
+two_step()
{
- if run_gitano_as "$1" user del "$2" 2> "$DATADIR/temp"
+ if "$@" 2> "$DATADIR/temp"
then
secret=$(awk '{ s = $2 } END { print s }' "$DATADIR/temp")
- run_gitano_as "$1" user del "$2" "$secret"
+ "$@" "$secret"
else
cat "$DATADIR/temp" 1>&2
return 1
@@ -81,6 +84,14 @@ user_del()
}
+# Remove a user from the server. This is a two-step process.
+
+user_del()
+{
+ two_step run_gitano_as "$1" user del "$2"
+}
+
+
# Does a repository exist?
repo_exists()
@@ -111,12 +122,5 @@ clone_with_ssh()
destroy_repo()
{
- if run_gitano_as "$1" destroy "$2" 2> "$DATADIR/temp"
- then
- secret=$(awk '{ s = $2 } END { print s }' "$DATADIR/temp")
- run_gitano_as "$1" destroy "$2" "$secret"
- else
- cat "$DATADIR/temp" 1>&2
- return 1
- fi
+ two_step run_gitano_as "$1" destroy "$2"
}