-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/sh | ||
|
||
# Get the list of paths to `Cargo.toml` files | ||
crates=$(find . -name Cargo.toml -exec dirname {} \; | sort) | ||
|
||
# Filter out crates that are not published to crates.io | ||
filter=("benches" "examples" "test") | ||
for f in "${filter[@]}"; do | ||
crates=$(echo "$crates" | grep -v "$f") | ||
done | ||
|
||
# Loop through each crate, while avoiding root workspace Cargo.toml | ||
for crate in $crates; do | ||
if [ "$crate" != "./protocols" ] && [ "$crate" != "./common" ] && [ "$crate" != "./roles" ] && [ "$crate" != "./utils" ]; then | ||
cd "$crate" | ||
|
||
# Check if there were any changes between dev and main | ||
git diff --quiet "dev" "main" -- . | ||
if [ $? -ne 0 ]; then | ||
|
||
# Check if crate versions on dev and main are identical | ||
version_dev=$(git show dev:./Cargo.toml | awk -F' = ' '$1 == "version" {gsub(/[ "]+/, "", $2); print $2}') | ||
version_main=$(git show main:./Cargo.toml | awk -F' = ' '$1 == "version" {gsub(/[ "]+/, "", $2); print $2}') | ||
if [ "$version_dev" = "$version_main" ]; then | ||
echo "Changes detected in crate $crate between dev and main branches! Versions on dev and main branches are identical ($version_dev), so you should bump the crate version on dev before merging into main." | ||
exit 1 | ||
fi | ||
fi | ||
|
||
cd - >/dev/null | ||
fi | ||
done |