fix(scripts): prevent octal interpretation in feature number parsing

When --number 027 was passed, printf '%03d' interpreted it as octal,
converting 027 (octal) to 23 (decimal). Now forces base-10 with 10# prefix.

Bug: User passes --number 027, gets feature 023 instead of 027
Root cause: printf %03d treats leading zeros as octal notation
Fix: Use $((10#$BRANCH_NUMBER)) to force decimal interpretation

Example:
- Before: --number 027 → octal 027 → decimal 23 → feature 023
- After: --number 027 → decimal 27 → feature 027

Note: PowerShell version does not have this bug because [int] type
conversion in PowerShell does not treat leading zeros as octal.
This commit is contained in:
Joseph Mearman
2025-11-25 13:50:25 +00:00
parent f65bf6ccb7
commit b4e1c07817

View File

@@ -246,7 +246,8 @@ if [ -z "$BRANCH_NUMBER" ]; then
fi
fi
FEATURE_NUM=$(printf "%03d" "$BRANCH_NUMBER")
# Force base-10 interpretation to prevent octal conversion (027 → 23)
FEATURE_NUM=$(printf "%03d" "$((10#$BRANCH_NUMBER))")
BRANCH_NAME="${FEATURE_NUM}-${BRANCH_SUFFIX}"
# GitHub enforces a 244-byte limit on branch names