From 08191869f53f76da1e3ae6aebe435a5ff461df96 Mon Sep 17 00:00:00 2001 From: leigh capili Date: Mon, 9 Nov 2020 10:56:08 -0700 Subject: [PATCH] Add helper scripts for cleaning up GREN release notes --- hack/find-extra-prs-not-in-git.sh | 41 +++++++++++++++++++ .../find-undocumented-release-prs-from-git.sh | 41 +++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100755 hack/find-extra-prs-not-in-git.sh create mode 100755 hack/find-undocumented-release-prs-from-git.sh diff --git a/hack/find-extra-prs-not-in-git.sh b/hack/find-extra-prs-not-in-git.sh new file mode 100755 index 000000000..4083e598a --- /dev/null +++ b/hack/find-extra-prs-not-in-git.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +PREVIOUS_TAG=${1} +RELEASE_NOTES=${2} + +usage() { + echo "This script is useful for finding extra PR's in a GREN generated release_notes/changelog file." + echo "It checks the GREN changelog for PR numbers that aren't present the git merge log on your local machine." + echo + echo "usage:" + echo " $0 " + echo + echo "example:" + echo " check for extra PR's in the v0.8.0 release notes" + echo + echo " $0 v0.7.1 ./docs/releases/v0.8.0.md" +} + +if ! [ "${1}" ] || ! [ "${2}" ]; then + usage + exit 1 +fi + +recent_prs_from_git() { + git log "${PREVIOUS_TAG}.." --merges --oneline | grep -o '#[1-9][0-9]*' +} + +release_note_prs() { + grep -o -E "pull/[0-9][0-9]*" "${RELEASE_NOTES}" | sed 's,pull/,#,' +} + +format_grep_filter() { + printf "|%s" "$@" | sed 's/^|//' +} + +missing_prs() { + release_note_prs | grep -v -E "$(format_grep_filter $(recent_prs_from_git))" +} + +hub pr list -s closed \ + | grep -E "$(format_grep_filter $(missing_prs))" diff --git a/hack/find-undocumented-release-prs-from-git.sh b/hack/find-undocumented-release-prs-from-git.sh new file mode 100755 index 000000000..60e2c276d --- /dev/null +++ b/hack/find-undocumented-release-prs-from-git.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +PREVIOUS_TAG=${1} +RELEASE_NOTES=${2} + +usage() { + echo "This script is useful for finding uncredited/undocumented PR's in a GREN generated release_notes/changelog file." + echo "It checks the git merge log on your local machine for PR numbers that aren't present in the GREN changelog." + echo + echo "usage:" + echo " $0 " + echo + echo "example:" + echo " check for PR's missing from the v0.8.0 release notes" + echo + echo " $0 v0.7.1 ./docs/releases/v0.8.0.md" +} + +if ! [ "${1}" ] || ! [ "${2}" ]; then + usage + exit 1 +fi + +recent_prs_from_git() { + git log "${PREVIOUS_TAG}.." --merges --oneline | grep -o '#[1-9][0-9]*' +} + +missing_prs() { + for pr in $(recent_prs_from_git); do + if ! grep "$pr" "${RELEASE_NOTES}" >/dev/null; then + echo "$pr" + fi + done +} + +format_grep_filter() { + printf "|%s" "$@" | sed 's/^|//' +} + +hub pr list -s closed \ + | grep -E "$(format_grep_filter $(missing_prs))"