Created
November 11, 2016 10:49
-
-
Save icio/1c3f334e303c83f0af51a6c91751cf05 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function go-local-package() { | |
go list ./... | head -1 | xargs dirname | |
} | |
function go-diff() { | |
ROOT_PKG=$(go-local-package) | |
go list -f '{{.Name}} {{.ImportPath}} {{.Deps}}' $(go list $ROOT_PKG/...) | \ | |
grep ^main | \ | |
grep -w -f <( | |
git diff --dirstat ${2:-master}...${1:-HEAD} | \ | |
awk '{ print "'$ROOT_PKG'/" $2 }' | \ | |
sed 's:/$::' | |
) | \ | |
awk '{ print $2 }' | |
} | |
function go-diff-file() { | |
go-diff "$@" | sed 's:^'$(go-local-package)/'::' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment