Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions scripts/semver-level.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,24 +77,24 @@ compute_semver_results() {
LEVEL="none"
elif [[ $SEMVER_EXIT_CODE -eq 1 ]]; then
# Check if it's an error or actual semver violation
if echo "$SEMVER_OUTPUT" | grep -qE "Summary semver requires new major version"; then
if grep -qE "Summary semver requires new major version" <<< "$SEMVER_OUTPUT"; then
# It's a semver violation - this is a major change
LEVEL="major"
REASON="cargo-semver-checks detected breaking changes"
# Extract the relevant violation details (skip the header/summary lines)
DETAILS=$(echo "$SEMVER_OUTPUT" | grep -A 1000 "^--- failure" | head -100 || echo "$SEMVER_OUTPUT" | tail -50)
DETAILS=$(grep -A 1000 "^--- failure" <<< "$SEMVER_OUTPUT" | head -100 || tail -50 <<< "$SEMVER_OUTPUT")
log_verbose "Detected semver violations (major change)" >&2
log_verbose "$SEMVER_OUTPUT" >&2
elif echo "$SEMVER_OUTPUT" | grep -qF "package \`$crate\` not found"; then
elif grep -qF "package \`$crate\` not found" <<< "$SEMVER_OUTPUT"; then
# The crate doesn't exist in the baseline — it's a new crate being added
LEVEL="minor"
REASON="New crate (not present in baseline)"
log_verbose "New crate '$crate' not found in baseline, treating as minor change" >&2
elif echo "$SEMVER_OUTPUT" | grep -qE "Summary semver requires new minor version"; then
elif grep -qE "Summary semver requires new minor version" <<< "$SEMVER_OUTPUT"; then
LEVEL="minor"
REASON="cargo-semver-checks detected minor breaking changes"
# Extract the relevant violation details (skip the header/summary lines)
DETAILS=$(echo "$SEMVER_OUTPUT" | grep -A 1000 "^--- failure" | head -100 || echo "$SEMVER_OUTPUT" | tail -50)
DETAILS=$(grep -A 1000 "^--- failure" <<< "$SEMVER_OUTPUT" | head -100 || tail -50 <<< "$SEMVER_OUTPUT")
log_verbose "Detected semver violations (minor change)" >&2
log_verbose "$SEMVER_OUTPUT" >&2
else
Expand Down Expand Up @@ -122,12 +122,12 @@ compute_semver_results() {
log_verbose "$PUBLIC_API_OUTPUT"

# Check for removed items (major change)
if echo "$PUBLIC_API_OUTPUT" | grep -q "Removed items from the public API$"; then
if ! echo "$PUBLIC_API_OUTPUT" | grep -A 2 "^Removed items from the public API$" | grep -q "^(none)$"; then
if grep -q "Removed items from the public API$" <<< "$PUBLIC_API_OUTPUT"; then
if ! grep -A 2 "^Removed items from the public API$" <<< "$PUBLIC_API_OUTPUT" | grep -q "^(none)$"; then
LEVEL="major"
REASON="cargo-public-api detected removed public API items"
# Extract removed items section
DETAILS=$(echo "$PUBLIC_API_OUTPUT" | grep -A 50 "^Removed items from the public API$" | head -50)
DETAILS=$(grep -A 50 "^Removed items from the public API$" <<< "$PUBLIC_API_OUTPUT" | head -50)
log_verbose "Detected removed items (major change)" >&2
fi
fi
Expand All @@ -139,12 +139,12 @@ compute_semver_results() {

# Check for added items (minor change) - only if not already major
if [[ "$LEVEL" != "major" ]]; then
if echo "$PUBLIC_API_OUTPUT" | grep -q "Added items to the public API$"; then
if ! echo "$PUBLIC_API_OUTPUT" | grep -A 2 "^Added items to the public API$" | grep -q "^(none)"; then
if grep -q "Added items to the public API$" <<< "$PUBLIC_API_OUTPUT"; then
if ! grep -A 2 "^Added items to the public API$" <<< "$PUBLIC_API_OUTPUT" | grep -q "^(none)"; then
LEVEL="minor"
REASON="cargo-public-api detected new public API items"
# Extract added items section
DETAILS=$(echo "$PUBLIC_API_OUTPUT" | grep -A 50 "^Added items to the public API$" | head -50)
DETAILS=$(grep -A 50 "^Added items to the public API$" <<< "$PUBLIC_API_OUTPUT" | head -50)
log_verbose "Detected added items (minor change)" >&2
fi
fi
Expand Down
Loading