From: Eric Biggers <ebiggers3@gmail.com>
To: Theodore Ts'o <tytso@mit.edu>
Cc: fstests@vger.kernel.org, Eric Biggers <ebiggers@google.com>
Subject: [PATCH 1/7] get-all: use helper function to clone repositories
Date: Thu, 25 May 2017 12:25:43 -0700 [thread overview]
Message-ID: <20170525192549.138518-2-ebiggers3@gmail.com> (raw)
In-Reply-To: <20170525192549.138518-1-ebiggers3@gmail.com>
From: Eric Biggers <ebiggers@google.com>
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@google.com>
---
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
next prev parent reply other threads:[~2017-05-25 19:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-25 19:25 [PATCH 0/7] xfstests-bld: get-all improvements and adding keyctl Eric Biggers
2017-05-25 19:25 ` Eric Biggers [this message]
2017-05-25 19:25 ` [PATCH 2/7] get-all: check out correct commits in already-cloned repositories Eric Biggers
2017-05-25 19:25 ` [PATCH 3/7] get-all: fail if optional repositories have been deconfigured Eric Biggers
2017-05-25 19:25 ` [PATCH 4/7] Makefile: always run get-all Eric Biggers
2017-05-25 19:25 ` [PATCH 5/7] do-all, get-all: run with 'set -e' Eric Biggers
2017-05-25 19:25 ` [PATCH 6/7] Makefile: check whether xfsprogs-dev exists before cleaning it Eric Biggers
2017-05-25 19:25 ` [PATCH 7/7] xfstests-bld: optionally build keyctl Eric Biggers
2017-05-27 3:37 ` [PATCH 0/7] xfstests-bld: get-all improvements and adding keyctl Theodore Ts'o
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170525192549.138518-2-ebiggers3@gmail.com \
--to=ebiggers3@gmail.com \
--cc=ebiggers@google.com \
--cc=fstests@vger.kernel.org \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox