Skip to content

Instantly share code, notes, and snippets.

@mediocregopher
Created February 1, 2016 21:11
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mediocregopher/22019c657d3fdf94215a to your computer and use it in GitHub Desktop.
Save mediocregopher/22019c657d3fdf94215a to your computer and use it in GitHub Desktop.
Prints out the revisions of all checked out dependencies of a go project that can be found in GOPATH
#!/bin/sh
function printDep {
dep="$1"
if [ "$dep" == "." ]; then return 0; fi
cd "$GOPATH/src/$dep"
if [ -d ".git" ]; then
echo "$dep (git) - $(git log --abbrev-commit --oneline -n 1)"
return 0
fi
if [ -d ".hg" ]; then
echo "$dep (hg) - $(hg log -l 1 --template '{node|short} {desc|firstline}')"
return 0
fi
if [ -d ".bzr" ]; then
echo "$dep (bzr) - $(bzr log -r-1 --line)"
return 0
fi
printDep "$(dirname $dep)"
}
exdep=$(go list -f '{{.Deps}}' | tr "[" " " | tr "]" " " | xargs go list -f '{{if not .Standard}}{{.ImportPath}}{{end}}')
for dep in $exdep; do
printDep "$dep"
done | sort | uniq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment