Created
May 17, 2018 20:09
-
-
Save narqo/eb79dfcb0d0c191c766980928897ce86 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
#!/usr/bin/env sh | |
# Usage: | |
# > to_deploy.sh <branch> <base_branch> | |
branch=${1:-HEAD} | |
base=${2:-"origin/master"} | |
declare -r mains=$(go list -json ./... | jq --compact-output '. | select(.Name == "main") | {ImportPath: .ImportPath, Deps: .Deps}') | |
declare -r changed=($(git diff --name-only ${base}...${branch} \ | |
| grep -v '_test.go$' \ | |
| grep '.go$' \ | |
| xargs -I % dirname % \ | |
| sort -u \ | |
)) | |
to_deploy=() | |
for pkg in ${changed[@]}; do | |
to_deploy+=($(echo "$mains" | jq --raw-output ". | select(.Deps[] | endswith(\"$pkg\")) | .ImportPath")) | |
done | |
echo ${to_deploy[@]} | tr ' ' '\n' | sort -u |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment