Skip to content

Commit

Permalink
Add changelog from status-go on upgrade #13090
Browse files Browse the repository at this point in the history
Signed-off-by: Audrius Molis <[email protected]>
Signed-off-by: Jakub Sokołowski <[email protected]>
  • Loading branch information
audriu authored and jakubgs committed Mar 7, 2022
1 parent cf606b9 commit 1eb956d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: nix-add-gcroots clean nix-clean run-metro test release _list _fix-node-perms _tmpdir-mk _tmpdir-rm
.PHONY: nix-add-gcroots clean nix-clean run-metro test release _list _fix-node-perms _tmpdir-mk _tmpdir-rm _install-hooks

help: SHELL := /bin/sh
help: ##@other Show this help
Expand Down Expand Up @@ -124,6 +124,11 @@ _tmpdir-rm: SHELL := /bin/sh
_tmpdir-rm: ##@prepare Remove TMPDIR
rm -fr "$(TMPDIR)"

_install-hooks: SHELL := /bin/sh
_install-hooks: ##@prepare Create prepare-commit-msg git hook symlink
@ln -s ../../scripts/hooks/prepare-commit-msg .git/hooks
-include _install-hooks

# Remove directories and ignored files
clean: SHELL := /bin/sh
clean: _fix-node-perms _tmpdir-rm ##@prepare Remove all output folders
Expand Down
21 changes: 21 additions & 0 deletions scripts/hooks/prepare-commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash
set -euo pipefail

if [[ -z $(git diff --cached --name-only -r | grep status-go-version.json) ]]; then
exit 0 # No status-go-version.json changes found.
fi

MERGE_BASE=$(git merge-base -a develop "$(git rev-parse --abbrev-ref HEAD)" develop)
GO_COMMIT_MERGE_BASE=$(git show "${MERGE_BASE}":status-go-version.json | jq -r '."commit-sha1"')
GO_COMMIT_CURRENT=$(jq -r '."commit-sha1"' status-go-version.json)
GITHUB_LINK_PREFIX="https://github.com/status-im/status-go/compare/"
# Link to the current StatusGo changelog being updated.
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
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

0 comments on commit 1eb956d

Please sign in to comment.