-
Notifications
You must be signed in to change notification settings - Fork 324
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backport of add make target script into release/1.2.x (#3600)
backport of commit 24f69ca Co-authored-by: Michael Wilkerson <mwilkerson@hashicorp.com>
- Loading branch information
1 parent
c84c5a9
commit 58a3ee0
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/bash | ||
|
||
CHECK=false | ||
|
||
# Check if the --check argument is passed | ||
for arg in "$@" | ||
do | ||
if [ "$arg" == "--check" ] | ||
then | ||
CHECK=true | ||
fi | ||
done | ||
|
||
# Find directories containing a go.mod file | ||
for dir in $(find . -type f -name go.mod -exec dirname {} \;); do | ||
# Change into the directory | ||
cd "$dir" || exit | ||
|
||
# Run go mod tidy | ||
echo "Running go mod tidy in $dir" | ||
go mod tidy | ||
|
||
# Change back to the original directory | ||
cd - || exit | ||
done | ||
|
||
# Check for differences if the --check argument was passed | ||
if [ "$CHECK" = true ]; then | ||
if [[ -n "$(git status --porcelain)" ]]; then | ||
echo "differences were found in go.mod or go.sum, run go mod tidy to fix them" | ||
exit 1 | ||
fi | ||
fi |