Skip to content

Instantly share code, notes, and snippets.

@Loupax
Created October 7, 2021 08:51
Show Gist options
  • Save Loupax/0c80cb8c3256f18875f9da8c9789c82c to your computer and use it in GitHub Desktop.
Save Loupax/0c80cb8c3256f18875f9da8c9789c82c to your computer and use it in GitHub Desktop.
Automatically reviews all changed files of a go project
function review_go_branch(){
compareAgainst="$1"
if [ -z "$compareAgainst" ]
then
compareAgainst="origin/master"
fi
files=($(git diff --name-status --diff-filter=ACM $compareAgainst | awk '{print $2}'))
if [ -z "$files" ]
then
return 0
fi
grepFiles=$(printf "\|^%s" "${files[@]}")
grepFiles=${grepFiles:2}
golangci-lint run ./... --out-format tab --config ~/.golangci.yaml | grep $grepFiles
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment