From 0dc50e1cde24af98f24a3e262ca8599451c4e777 Mon Sep 17 00:00:00 2001 From: Maciej Szeszko Date: Fri, 6 Dec 2024 14:44:22 -0800 Subject: [PATCH 1/4] Refresh check_buck_targets.sh --- buckifier/check_buck_targets.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/buckifier/check_buck_targets.sh b/buckifier/check_buck_targets.sh index 66c83c52f37..5c207be3b84 100755 --- a/buckifier/check_buck_targets.sh +++ b/buckifier/check_buck_targets.sh @@ -3,30 +3,30 @@ # If clang_format_diff.py command is not specfied, we assume we are able to # access directly without any path. -TGT_DIFF=`git diff TARGETS | head -n 1` +TGT_DIFF=`git diff BUCK | head -n 1` if [ ! -z "$TGT_DIFF" ] then - echo "TARGETS file has uncommitted changes. Skip this check." + echo "BUCK file has uncommitted changes. Skip this check." exit 0 fi -echo Backup original TARGETS file. +echo Backup original BUCK file. -cp TARGETS TARGETS.bkp +cp BUCK BUCK.bkp ${PYTHON:-python3} buckifier/buckify_rocksdb.py -TGT_DIFF=`git diff TARGETS | head -n 1` +TGT_DIFF=`git diff BUCK | head -n 1` if [ -z "$TGT_DIFF" ] then - mv TARGETS.bkp TARGETS + mv BUCK.bkp BUCK exit 0 else - echo "Please run '${PYTHON:-python3} buckifier/buckify_rocksdb.py' to update TARGETS file." - echo "Do not manually update TARGETS file." + echo "Please run '${PYTHON:-python3} buckifier/buckify_rocksdb.py' to update BUCK file." + echo "Do not manually update BUCK file." ${PYTHON:-python3} --version - mv TARGETS.bkp TARGETS + mv BUCK.bkp BUCK exit 1 fi From f34cbd86c93b0d8084264eeb227e84843576fcc9 Mon Sep 17 00:00:00 2001 From: Maciej Szeszko Date: Fri, 6 Dec 2024 17:29:36 -0800 Subject: [PATCH 2/4] Fail loudly if BUCK file goes missing after running buckify_rocksdb.py script --- buckifier/check_buck_targets.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/buckifier/check_buck_targets.sh b/buckifier/check_buck_targets.sh index 5c207be3b84..d5475354523 100755 --- a/buckifier/check_buck_targets.sh +++ b/buckifier/check_buck_targets.sh @@ -1,7 +1,5 @@ #!/usr/bin/env bash # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. -# If clang_format_diff.py command is not specfied, we assume we are able to -# access directly without any path. TGT_DIFF=`git diff BUCK | head -n 1` @@ -17,6 +15,13 @@ cp BUCK BUCK.bkp ${PYTHON:-python3} buckifier/buckify_rocksdb.py +if [[ ! -f "BUCK" ]] +then + echo "buckifier/buckify_rocksdb.py was expected to (re)generate BUCK file." + echo "BUCK file is missing!" + exit 1 +fi + TGT_DIFF=`git diff BUCK | head -n 1` if [ -z "$TGT_DIFF" ] From b86d9f58cb35bbfcbda7938efdc7e924f44db16d Mon Sep 17 00:00:00 2001 From: Maciej Szeszko Date: Fri, 6 Dec 2024 17:49:21 -0800 Subject: [PATCH 3/4] Add safety check to verify BUCK file exists at the beginning --- buckifier/check_buck_targets.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/buckifier/check_buck_targets.sh b/buckifier/check_buck_targets.sh index d5475354523..db8ef8950e3 100755 --- a/buckifier/check_buck_targets.sh +++ b/buckifier/check_buck_targets.sh @@ -1,6 +1,12 @@ #!/usr/bin/env bash # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. +if [[ ! -f "BUCK" ]] +then + echo "BUCK file is missing!" + exit 1 +fi + TGT_DIFF=`git diff BUCK | head -n 1` if [ ! -z "$TGT_DIFF" ] From b4af0b9825ab9feec35e4f1b6242437eeb19765e Mon Sep 17 00:00:00 2001 From: Maciej Szeszko Date: Sun, 8 Dec 2024 15:45:48 -0800 Subject: [PATCH 4/4] Rephrase errors for better readability --- buckifier/check_buck_targets.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/buckifier/check_buck_targets.sh b/buckifier/check_buck_targets.sh index db8ef8950e3..0f648c4fbf4 100755 --- a/buckifier/check_buck_targets.sh +++ b/buckifier/check_buck_targets.sh @@ -4,6 +4,7 @@ if [[ ! -f "BUCK" ]] then echo "BUCK file is missing!" + echo "Please do not remove / rename BUCK file in your commit(s)." exit 1 fi @@ -23,8 +24,8 @@ ${PYTHON:-python3} buckifier/buckify_rocksdb.py if [[ ! -f "BUCK" ]] then - echo "buckifier/buckify_rocksdb.py was expected to (re)generate BUCK file." - echo "BUCK file is missing!" + echo "BUCK file went missing after running buckifier/buckify_rocksdb.py!" + echo "Please do not remove the BUCK file." exit 1 fi