From a35edc7553cdf6fa6d6ed843c3ccd9cd2e0a8663 Mon Sep 17 00:00:00 2001 From: Nick Allen Date: Sat, 12 May 2018 16:01:32 -0400 Subject: [PATCH 1/2] METRON-1553 Validate JIRA Script Error --- dev-utilities/release-utils/validate-jira-for-release | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/dev-utilities/release-utils/validate-jira-for-release b/dev-utilities/release-utils/validate-jira-for-release index df5776cb9d..2234c60ecc 100755 --- a/dev-utilities/release-utils/validate-jira-for-release +++ b/dev-utilities/release-utils/validate-jira-for-release @@ -137,7 +137,6 @@ for i in "$@"; do esac done -WORKDIR="~/tmp" # ensure all required values are set if [ -z "$VERSION" ]; then @@ -162,10 +161,15 @@ if [ -z "$BRANCH" ]; then fi # clone the metron repo and fetch all tags +TMPDIR="$HOME/tmp" +cd $TMPDIR git clone $REPO "metron-$VERSION" + +WORKDIR="$TMPDIR/metron-$VERSION" +echo "Working directory: $WORKDIR..." +cd "$WORKDIR" git checkout $BRANCH -cd "$WORKDIR/metron-$VERSION" -git fetch --all --tags +git fetch --tags # find all JIRAs that have been committed since the last release GET_JIRAS="git log $START..$END --oneline | grep -E -o 'METRON[- ]*[0-9]+'" From 35be039549611b45ffa8d3c4512959d4187a5b16 Mon Sep 17 00:00:00 2001 From: Nick Allen Date: Tue, 5 Jun 2018 11:40:24 -0400 Subject: [PATCH 2/2] Warn the user if the directory exists per @justinleet --- .../release-utils/validate-jira-for-release | 71 +++++++++++-------- 1 file changed, 42 insertions(+), 29 deletions(-) diff --git a/dev-utilities/release-utils/validate-jira-for-release b/dev-utilities/release-utils/validate-jira-for-release index 2234c60ecc..5fd4367b07 100755 --- a/dev-utilities/release-utils/validate-jira-for-release +++ b/dev-utilities/release-utils/validate-jira-for-release @@ -140,33 +140,46 @@ done # ensure all required values are set if [ -z "$VERSION" ]; then - echo "Missing -v/--version is is required" - exit 1 + help + echo "Missing -v/--version is is required" + exit 1 fi if [ -z "$START" ]; then - echo "Missing -s/--start which is required" - exit 1 + help + echo "Missing -s/--start which is required" + exit 1 fi if [ -z "$END" ]; then - echo "Missing -e/--end which is required" - exit 1 + help + echo "Missing -e/--end which is required" + exit 1 fi if [ -z "$REPO" ]; then - echo "Missing -r/--repo which is required" - exit 1 + help + echo "Missing -r/--repo which is required" + exit 1 fi if [ -z "$BRANCH" ]; then - echo "Missing -b/--branch which is required" - exit 1 + help + echo "Missing -b/--branch which is required" + exit 1 fi -# clone the metron repo and fetch all tags TMPDIR="$HOME/tmp" -cd $TMPDIR -git clone $REPO "metron-$VERSION" - WORKDIR="$TMPDIR/metron-$VERSION" -echo "Working directory: $WORKDIR..." + +# warn the user if the working directory exists +if [ -d "$WORKDIR" ]; then + read -p " directory exists [$WORKDIR]. overwrite existing repo? [yN] " -n 1 -r + echo + if [[ ! $REPLY =~ ^[Yy]$ ]]; then + exit 1 + fi +fi + +# fetch the repo and all tags +rm -rf "$WORKDIR" +git clone $REPO "$WORKDIR" cd "$WORKDIR" git checkout $BRANCH git fetch --tags @@ -181,21 +194,21 @@ printf "$FORMAT_STR" "JIRA" "STATUS" "FIX VERSION" "ASSIGNEE" "FIX" # for each JIRA since the last release tag... eval $GET_JIRAS | while read JIRA ; do - # fetch the JIRA content - URL="https://issues.apache.org/jira/si/jira.issueviews:issue-xml/$JIRA/$JIRA.xml" - CONTENT=`curl -s $URL` + # fetch the JIRA content + URL="https://issues.apache.org/jira/si/jira.issueviews:issue-xml/$JIRA/$JIRA.xml" + CONTENT=`curl -s $URL` - # painfully extract some fields - STATUS=`echo "$CONTENT" | grep "]*>" | sed 's/^.*]*>//' | sed 's/<.status>.*$//'` - ASSIGNEE=`echo "$CONTENT" | grep "]*>" | sed 's/^.*]*>//' | sed 's/<.assignee>.*$//'` - FIXV=`echo "$CONTENT" | grep "]*>" | sed 's/^.*]*>//' | sed 's/<.fixVersion>.*$//'` + # painfully extract some fields + STATUS=`echo "$CONTENT" | grep "]*>" | sed 's/^.*]*>//' | sed 's/<.status>.*$//'` + ASSIGNEE=`echo "$CONTENT" | grep "]*>" | sed 's/^.*]*>//' | sed 's/<.assignee>.*$//'` + FIXV=`echo "$CONTENT" | grep "]*>" | sed 's/^.*]*>//' | sed 's/<.fixVersion>.*$//'` - # the link is only populated, if there is something to fix - LINK="" - if [ "$FIXV" != "$VERSION" ] || [ "$STATUS" != "Done" ]; then - LINK="https://issues.apache.org/jira/browse/$JIRA" - fi + # the link is only populated, if there is something to fix + LINK="" + if [ "$FIXV" != "$VERSION" ] || [ "$STATUS" != "Done" ]; then + LINK="https://issues.apache.org/jira/browse/$JIRA" + fi - # show the JIRA - printf "$FORMAT_STR" "$JIRA" "$STATUS" "$FIXV" "$ASSIGNEE" "$LINK" + # show the JIRA + printf "$FORMAT_STR" "$JIRA" "$STATUS" "$FIXV" "$ASSIGNEE" "$LINK" done