Skip to content

Commit 438fcda

Browse files
committed
Add a hook to reject SNAPSHOT dependencies
If your POM has a SNAPSHOT reference other than to the parent, it is rejected. This is a simple yet effective check to ensure no SNAPSHOT dependencies get accidentally introduced.
1 parent 03dda26 commit 438fcda

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

hooks/pre-commit-no-snapshots.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
3+
# Fail if any pom.xml files have more than one SNAPSHOT reference.
4+
# One reference to the parent is expected, but that's it!
5+
# Otherwise, builds will not be repeatable.
6+
if git grep -c SNAPSHOT $(git ls-files | grep pom.xml) | grep -v ':1$';
7+
then
8+
echo 'Potential SNAPSHOT references!'
9+
exit 1
10+
fi

0 commit comments

Comments
 (0)