Skip to content

Commit 8566f0a

Browse files
committed
Fix pre-commit: Handle projects without go.sum
- go.sum only exists when there are external dependencies - This project uses only Go standard library - Update check to handle go.sum being optional
1 parent 2a4a3d9 commit 8566f0a

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

.github/workflows/pre-commit.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,15 @@ jobs:
4242
- name: Run go mod tidy check
4343
run: |
4444
go mod tidy
45-
if ! git diff --exit-code go.mod go.sum; then
46-
echo "go.mod or go.sum is not tidy. Run 'go mod tidy' to fix."
45+
# Check if go.mod has changed (go.sum may not exist if no dependencies)
46+
if ! git diff --exit-code go.mod; then
47+
echo "go.mod is not tidy. Run 'go mod tidy' to fix."
4748
exit 1
4849
fi
50+
# Check go.sum only if it exists
51+
if [ -f go.sum ]; then
52+
if ! git diff --exit-code go.sum; then
53+
echo "go.sum is not tidy. Run 'go mod tidy' to fix."
54+
exit 1
55+
fi
56+
fi

0 commit comments

Comments
 (0)