From 1b9e1392553cdce2240a5a0e98b804243b470cd8 Mon Sep 17 00:00:00 2001 From: Audrius Molis Date: Sat, 19 Mar 2022 15:39:30 +0200 Subject: [PATCH] Fix sed command to work on mac Signed-off-by: Audrius Molis --- scripts/hooks/prepare-commit-msg | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/hooks/prepare-commit-msg b/scripts/hooks/prepare-commit-msg index 369cca6a43..8cd2e832d3 100755 --- a/scripts/hooks/prepare-commit-msg +++ b/scripts/hooks/prepare-commit-msg @@ -14,9 +14,9 @@ GITHUB_LINK="${GITHUB_LINK_PREFIX}${GO_COMMIT_MERGE_BASE}...${GO_COMMIT_CURRENT} COMMIT_MSG_FILE=$1 # Check if the commit message already contains the link (rebase) and update otherwise insert into line2 -# temporary comment out because of the error on macos -#if ! grep -qF "${GITHUB_LINK_PREFIX}" "${COMMIT_MSG_FILE}" >/dev/null; then -# sed -in "2i${GITHUB_LINK}\n" "${COMMIT_MSG_FILE}" -#else -# sed -in "s;^${GITHUB_LINK_PREFIX}.*$;${GITHUB_LINK};" "${COMMIT_MSG_FILE}" -#fi +if ! grep -qF "${GITHUB_LINK_PREFIX}" "${COMMIT_MSG_FILE}" >/dev/null; then + sed -in'' -e "2i\\ +${GITHUB_LINK}\n" "${COMMIT_MSG_FILE}" +else + sed -in'' -e "s;^${GITHUB_LINK_PREFIX}.*$;${GITHUB_LINK};" "${COMMIT_MSG_FILE}" +fi