This repository has been archived by the owner on Jan 10, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
1 parent
48b8381
commit 3ded9ca
Showing
1 changed file
with
25 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,25 @@ | ||
# Source this file. | ||
# | ||
# Detects any manifests whose versions have changed. | ||
# Does so by comparing the current version in the Cargo.toml with the previous | ||
# version in the last commit. Intended for squash-merged PRs. | ||
|
||
detect_changed_manifests() { | ||
local changed_manifests=() | ||
local cargo_toml_files=$(find . -name "Cargo.toml") | ||
|
||
for file in $cargo_toml_files; do | ||
# Get the current version from the manifest. | ||
local current_version=$(grep -E '^version\s*=' "$file" | sed -E 's/version\s*=\s*"(.*)"/\1/') | ||
|
||
# Get the previous version from the last commit. | ||
local previous_version=$(git show HEAD~1:"$file" | grep -E '^version\s*=' | sed -E 's/version\s*=\s*"(.*)"/\1/' 2>/dev/null) | ||
|
||
# Compare the versions and add the path to the list if they are different. | ||
if [ "$current_version" != "$previous_version" ]; then | ||
changed_manifests+=("$file") | ||
fi | ||
done | ||
|
||
echo "${changed_manifests[@]}" | ||
} |