From be75d0225d6cdbcb685c193c53d190b7e986737c Mon Sep 17 00:00:00 2001 From: Jack Baldry Date: Mon, 4 Dec 2023 12:41:16 +0000 Subject: [PATCH 1/2] Add check for running in the root of the repository ```console $ ../scripts/apply-patch HEAD~ sources/next sources/v0.47.x ERROR: Script has not been run from the repository root ('/Users/jdb/ext/grafana/k6-docs'). Please change directory there and adjust argument paths to match the new working directory. ``` Signed-off-by: Jack Baldry --- scripts/apply-patch | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/apply-patch b/scripts/apply-patch index ebf7c921d9..da98d7028f 100755 --- a/scripts/apply-patch +++ b/scripts/apply-patch @@ -3,6 +3,7 @@ function usage { cat < @@ -50,5 +51,13 @@ function path_components { echo "${n}" } +GIT_ROOT="$(git rev-parse --show-toplevel)" +if [[ "$(pwd)" != "${GIT_ROOT}" ]]; then + echo "ERROR: Script has not been run from the repository root ('${GIT_ROOT}')." + echo "Please change directory there and adjust argument paths to match the new working directory." + + exit 1 +fi + git diff "${COMMIT}" -- "${SRC}" > "${PATCH}" git apply -p "$(path_components "${SRC}")" --directory "${DST}" "${PATCH}" From a306bbc794099a3f86f67bf9f625e2aaf7504555 Mon Sep 17 00:00:00 2001 From: Jack Baldry Date: Mon, 4 Dec 2023 18:53:46 +0000 Subject: [PATCH 2/2] Shorten instruction Co-authored-by: Heitor Tashiro Sergent --- scripts/apply-patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/apply-patch b/scripts/apply-patch index da98d7028f..54ad1eaf85 100755 --- a/scripts/apply-patch +++ b/scripts/apply-patch @@ -54,7 +54,7 @@ function path_components { GIT_ROOT="$(git rev-parse --show-toplevel)" if [[ "$(pwd)" != "${GIT_ROOT}" ]]; then echo "ERROR: Script has not been run from the repository root ('${GIT_ROOT}')." - echo "Please change directory there and adjust argument paths to match the new working directory." + echo "Please move to the root directory and re-run the script." exit 1 fi