[PATCH 1/7] get-all: use helper function to clone repositories

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]



From: Eric Biggers <ebiggers@xxxxxxxxxx>

Add a function which handles cloning a repository and optionally
checking out a specific commit, then use it for all the repositories.

Signed-off-by: Eric Biggers <ebiggers@xxxxxxxxxx>
---
 get-all | 119 ++++++++++++++++++++++------------------------------------------
 1 file changed, 40 insertions(+), 79 deletions(-)

diff --git a/get-all b/get-all
index fc4dc2d..67a54b4 100755
--- a/get-all
+++ b/get-all
@@ -6,88 +6,49 @@ else
 	. config
 fi
 
-if test ! -d xfsprogs-dev
-then
-	if test -z "$XFSPROGS_GIT"; then
-		echo "XFSPROGS_GIT not set; check your config file!"
-		exit 1
-        fi
-	if ! git clone $XFSPROGS_GIT xfsprogs-dev; then
-		echo "Failed to get xfsprogs-dev from $XFSPROGS_GIT"
-                exit 1
-	fi
-	if test -n "$XFSPROGS_COMMIT"; then
-		cd xfsprogs-dev
-		git branch xfstests-bld $XFSPROGS_COMMIT
-		git checkout xfstests-bld
-		cd ..
-	fi
-fi
-if test ! -d xfstests-dev
-then
-	if test -z "$XFSTESTS_GIT"; then
-		echo "XFSTESTS_GIT not set; check your config file!"
-		exit 1
-        fi
-	if ! git clone $XFSTESTS_GIT xfstests-dev; then
-		echo "Failed to get xfstests-dev from $XFSTESTS_GIT"
-                exit 1
-	fi
-	if test -n "$XFSTESTS_COMMIT"; then
-		cd xfstests-dev
-		git branch xfstests-bld $XFSTESTS_COMMIT
-		git checkout xfstests-bld
-		cd ..
-	fi
-fi
-if test ! -d fio
-then
-	if test -z "$FIO_GIT"; then
-		echo "FIO_GIT not set; check your config file!"
-		exit 1
-        fi
-	if ! git clone $FIO_GIT fio; then
-		echo "Failed to get fio from $FIO_GIT"
-                exit 1
-	fi
-	if test -n "$FIO_COMMIT"; then
-		cd fio
-		git branch xfstests-bld $FIO_COMMIT
-		git checkout xfstests-bld
-		cd ..
-	fi
-fi
-if test ! -d quota
-then
-	if test -z "$QUOTA_GIT"; then
-		echo "QUOTA_GIT not set; check your config file!"
-		exit 1
-        fi
-	if ! git clone $QUOTA_GIT quota; then
-		echo "Failed to get quota from $QUOTA_GIT"
-                exit 1
-	fi
-	if test -n "$QUOTA_COMMIT"; then
-		cd quota
-		git branch xfstests-bld $QUOTA_COMMIT
-		git checkout xfstests-bld
-		cd ..
-	fi
-fi
+setup_repo()
+{
+    local repo_name="$1"
+    local repo_url_variable="$2"
+    local repo_url="${!2}"
+    local commit_variable="$3"
+    local commit="${!3}"
+    local required="$4"
 
-if test ! -d stress-ng -a -n "$STRESS_NG_GIT"
-then
-	if ! git clone $STRESS_NG_GIT stress-ng; then
-		echo "Failed to get stress-ng from $STRESS_NG_GIT"
-                exit 1
+    # Clone the repository if needed.
+    if [ ! -d "$repo_name" ]; then
+	if [ -z "$repo_url" ]; then
+	    if ! $required; then
+		return
+	    fi
+	    echo 1>&2 "$repo_url_variable not set; check your config file!"
+	    exit 1
 	fi
-	if test -n "$STRESS_NG_COMMIT"; then
-		cd stress-ng
-		git branch xfstests-bld $STRESS_NG_COMMIT
-		git checkout xfstests-bld
-		cd ..
+
+	echo
+	if ! git clone "$repo_url" "$repo_name"; then
+	    echo 1>&2 "Failed to clone $repo_name from $repo_url"
+	    exit 1
 	fi
-fi
+
+	# If a specific commit was specified, check it out.
+	if [ -n "$commit" ]; then
+	    ( cd "$repo_name";
+	      git branch xfstests-bld "$commit";
+	      git checkout xfstests-bld;
+	    )
+	fi
+    fi
+}
+
+# required repositories
+setup_repo fio			FIO_GIT		FIO_COMMIT		true
+setup_repo quota		QUOTA_GIT	QUOTA_COMMIT		true
+setup_repo xfsprogs-dev		XFSPROGS_GIT	XFSPROGS_COMMIT		true
+setup_repo xfstests-dev		XFSTESTS_GIT	XFSTESTS_COMMIT		true
+
+# optional repositories
+setup_repo stress-ng		STRESS_NG_GIT	STRESS_NG_COMMIT	false
 
 # Make sure acl doesn't try regenerate these files because of the
 # vagrancies of the timestamps when they were checked out
-- 
2.13.0.219.gdb65acc882-goog

--
To unsubscribe from this list: send the line "unsubscribe fstests" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Filesystems Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux