Skip to content

Commit

Permalink
Merge pull request #47 from pote/set-dependencies-refactor
Browse files Browse the repository at this point in the history
Set dependencies refactor
  • Loading branch information
Pablo Astigarraga committed Sep 16, 2014
2 parents 8b05d57 + f61505f commit 09c8546
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
13 changes: 13 additions & 0 deletions Godeps.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Git repos
github.com/nu7hatch/gotrail v0.0.2
github.com/replicon/fast-archiver v1.02

# Subpackages
github.com/garyburd/redigo/redis a6a0a737c00caf4d4c2bb589941ace0d688168bb

# Bazaar Repo
launchpad.net/gocheck r2013.03.03

# Mercurial Repo
code.google.com/p/go.example/hello/... ae081cd1d6cc

21 changes: 10 additions & 11 deletions bin/gpm
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,23 @@ set_dependencies() {

while read package version; do
(
local pkg_path=$(echo "$package" | awk -F/ '{print $1"/"$2"/"$3}')
local install_path="${GOPATH%%:*}/src/${pkg_path%%/...}"
echo ">> Getting package "$package""
go get -u -d "$package"
) &
done < <(echo "$deps")
wait

# Retries in case of possible race conditions when installing a package
# dependency
for ((i=0; i<5; i++)); do
out=$(go get -u -d "$package" 2>&1 >/dev/null) && break
done
[[ $? != 0 ]] && echo "-- Failed to get "$package", error: " && echo "$out" && exit 1

while read package version; do
(
local pkg_path=$(echo "$package" | awk -F/ '{print $1"/"$2"/"$3}')
local install_path="${GOPATH%%:*}/src/${pkg_path%%/...}"
echo ">> Setting $package to version $version"
cd $install_path
is_in_use $install_path && wait

[ -d .hg ] && hg update -q "$version"
[ -d .git ] && git checkout -q "$version"
[ -d .bzr ] && bzr revert -q -r "$version"
[ -d .git ] && git checkout -q "$version"
[ -d .hg ] && hg update -q "$version"
[ -d .svn ] && svn update -r "$version"
) &
done < <(echo "$deps")
Expand Down
6 changes: 4 additions & 2 deletions test/installs_correct_versions_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ assert "go run go_code.go" "v6.2"
version="a6a0a737c00caf4d4c2bb589941ace0d688168bb"
echo "github.com/garyburd/redigo/redis $version" > Godeps
assert_raises "$GPM"
rm Godeps
cd $GOPATH/src/github.com/garyburd/redigo
cd "${GOPATH%%:*}/src/github.com/garyburd/redigo"
assert "git rev-parse HEAD" "$version"

## Cleanup
rm Godeps

assert_end examples

0 comments on commit 09c8546

Please sign in to comment.