From 56b9608cce9f489e27f0703f158c2158a4bbc027 Mon Sep 17 00:00:00 2001 From: Chris Kowalik Date: Wed, 7 Aug 2013 21:36:55 -0300 Subject: [PATCH 1/2] removed repetitions in reading from file and comments redone in unixy style with sed --- bin/johnny_deps | 7 +++---- test/commented_lines_are_ignored_test.sh | 10 +++++++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/bin/johnny_deps b/bin/johnny_deps index bbc7534..2f4fe4f 100755 --- a/bin/johnny_deps +++ b/bin/johnny_deps @@ -11,19 +11,18 @@ set -eu root=$PWD godeps=${1-"Godeps"} +deps=$(sed -e 's/#.*//' < "$godeps" | grep -P ".+") while read package version; do - [[ -z "$package" || "$package" =~ ^# ]] && continue go get -v -u -d "$package" echo "Setting $package to version $version" cd "${GOPATH%%:*}/src/${package%%/...}" git checkout "$version" -done < "$godeps" +done < <(echo "$deps") cd "$root" while read package version; do - [[ -z "$package" || "$package" =~ ^# ]] && continue echo "Installing $package" go install "$package" -done < "$godeps" +done < <(echo "$deps") diff --git a/test/commented_lines_are_ignored_test.sh b/test/commented_lines_are_ignored_test.sh index aec0ac9..021ed93 100755 --- a/test/commented_lines_are_ignored_test.sh +++ b/test/commented_lines_are_ignored_test.sh @@ -2,9 +2,13 @@ . assert.sh # Setting up v5.0 of package -echo "github.com/pote/johnny-deps-testing-package v5.0" > Godeps -echo "#github.com/pote/johnny-deps-testing-package v5.1" >> Godeps -echo "# github.com/pote/johnny-deps-testing-package v5.1" >> Godeps +cat > Godeps < Date: Thu, 8 Aug 2013 13:16:39 -0300 Subject: [PATCH 2/2] deleting comments and empty lines in single command --- bin/johnny_deps | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/johnny_deps b/bin/johnny_deps index 2f4fe4f..0f1168b 100755 --- a/bin/johnny_deps +++ b/bin/johnny_deps @@ -11,7 +11,7 @@ set -eu root=$PWD godeps=${1-"Godeps"} -deps=$(sed -e 's/#.*//' < "$godeps" | grep -P ".+") +deps=$(sed 's/#.*//;/^\s*$/d' < "$godeps") while read package version; do go get -v -u -d "$package"