Skip to content

Commit

Permalink
Add additional info messages for users
Browse files Browse the repository at this point in the history
  • Loading branch information
xorcare committed Sep 22, 2024
1 parent 1742d54 commit a98f21e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
21 changes: 17 additions & 4 deletions .github/workflows/shell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,25 +49,38 @@ jobs:
git config user.email "you@example.com"
git config user.name "Your Name"
- name: Test help flags
- name: Zero exit code when use help flags
working-directory: tornado
run: |
../go-mod-bump.sh -h
../go-mod-bump.sh -help
- name: Default exit code must be zero
- name: Zero exit code when module name is not set
working-directory: tornado
run: |
../go-mod-bump.sh
- name: Test bump '${{ matrix.pkg }}'
- name: Update dependencies when there is something to update
working-directory: tornado
run: |
git checkout --quiet 029fe5d254ab71c1e72444adcda808f5a494084d
git checkout --force --quiet 029fe5d254ab71c1e72444adcda808f5a494084d
../go-mod-bump.sh ${{ matrix.pkg }}
commit_count=$(git rev-list --count HEAD ^029fe5d254ab71c1e72444adcda808f5a494084d)
if [[ "$commit_count" == 0 ]]; then
echo "ERROR: No changes have been detected, but they must be exist"
exit 1
fi
git diff 029fe5d254ab71c1e72444adcda808f5a494084d
- name: Zero exit code when nothing to update
working-directory: tornado
run: |
git checkout --force --quiet 029fe5d254ab71c1e72444adcda808f5a494084d
../go-mod-bump.sh ${{ matrix.pkg }} # update
../go-mod-bump.sh ${{ matrix.pkg }} # nothing to update
- name: Zero exit code when no have direct modules
working-directory: testo
run: |
go mod init testo
../go-mod-bump.sh ${{ matrix.pkg }}
12 changes: 11 additions & 1 deletion go-mod-bump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,24 @@ readonly GO_LIST_FORMAT_DIRECT
DIRECT_MODULES=$(go list -m -f "$GO_LIST_FORMAT_DIRECT" $@ | grep -v '<SKIP>')
readonly DIRECT_MODULES

if [ -z "$DIRECT_MODULES" ]; then
echoerr "go-mod-bump: nothing to update (no direct modules found)"
exit 0
fi

GO_LIST_FORMAT_FOR_UPDATE='{{.Path}}@{{.Version}}@{{if .Update}}{{.Update.Version}}{{end}}'
GO_LIST_FORMAT_FOR_UPDATE+='{{if not .Update}}<SKIP>{{end}}' # skip modules without updates.
readonly GO_LIST_FORMAT_FOR_UPDATE

# shellcheck disable=SC2086
MODULES_FOR_UPDATE=$(go list -m -u -f "$GO_LIST_FORMAT_FOR_UPDATE" $DIRECT_MODULES | grep -v '<SKIP>')
MODULES_FOR_UPDATE=$(go list -m -u -f "$GO_LIST_FORMAT_FOR_UPDATE" $DIRECT_MODULES | grep -v '<SKIP>' || true)
readonly MODULES_FOR_UPDATE

if [ -z "$MODULES_FOR_UPDATE" ]; then
echoerr "go-mod-bump: nothing to update (no new versions found)"
exit 0
fi

function update_module() {
go get "$1"

Expand Down

0 comments on commit a98f21e

Please sign in to comment.