Skip to content

Commit 5d51fbe

Browse files
authored
Merge pull request #33 from xnox/xnox/epoch-bump-across-package-dirs
check-for-epoch-bump: enforce epoch bump when package moves between dirs
2 parents 1148b71 + d5a79c9 commit 5d51fbe

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

scripts/check-for-epoch-bump.sh

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,19 @@ for yaml_file in "$@"; do
4545

4646
# Extract version and epoch from the file on the main branch using git show
4747
# Treat missing file as version 0 and epoch 0
48-
main_content="$(git show main:"$yaml_file" 2>/dev/null)"
48+
# Try all three known package directories so epoch bumps are enforced when
49+
# a package is moved between os/, enterprise-packages/, and extra-packages/.
50+
first_component="${yaml_file%%/*}"
51+
rest_of_path="${yaml_file#*/}"
52+
main_content=""
53+
if [[ "$first_component" == "os" || "$first_component" == "enterprise-packages" || "$first_component" == "extra-packages" ]]; then
54+
for prefix in "os" "enterprise-packages" "extra-packages"; do
55+
main_content="$(git show main:"${prefix}/${rest_of_path}" 2>/dev/null)"
56+
[ -n "$main_content" ] && break
57+
done
58+
else
59+
main_content="$(git show main:"$yaml_file" 2>/dev/null)"
60+
fi
4961
if [ -z "$main_content" ]; then
5062
version_main="0"
5163
epoch_main="0"

0 commit comments

Comments
 (0)