Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Commit

Permalink
add detect-changed-manifests script
Browse files Browse the repository at this point in the history
  • Loading branch information
buffalojoec committed Aug 13, 2024
1 parent 48b8381 commit 3ded9ca
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions ci/detect-changed-manifests.sh
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[@]}"
}

0 comments on commit 3ded9ca

Please sign in to comment.