Skip to content

Instantly share code, notes, and snippets.

@buckett
Forked from juanjmerono/chcherrypick.sh
Last active February 25, 2016 16:26
Show Gist options
  • Save buckett/5d0cb0bad38238e71e68 to your computer and use it in GitHub Desktop.
Save buckett/5d0cb0bad38238e71e68 to your computer and use it in GitHub Desktop.
Script to list pending commits in 11.x branch
#!/bin/bash
#
# You must run this in the Sakai working directory in master branch
# chcherrypick.sh -u (to update your repo)
# chcherrypick.sh -m (to check the list of pending cherry picks even they are not Verified in jira)
# chcherrypick.sh (to check the list of pending cherry picks)
#
SEPARATOR=$'\n'"###"
SEPARATOREND="###"
CNT=1
LASTISSUE=""
MERGE=""
CHECKST="Merge.*Verified"
if [ "$1" == "-u" ]
then
echo "Updating git repo..."
git checkout 11.x
git pull upstream 11.x
git checkout master
git pull upstream master
else
if [ "$1" == "-m" ]
then
CHECKST="Merge"
fi
for f in $(git cherry 11.x master -v | awk '{if ( $1=="+" ) print $3 " " substr($2,0,7);}' | sort -k1); do
if [ $((CNT%2)) -eq 0 ]
then
if [ "$MERGE" == "11" ]
then
echo "git cherry-pick $f"
fi
else
ISSUE="$f"
if [ "$LASTISSUE" != "$ISSUE" ]
then
LASTISSUE=$ISSUE
if [[ $ISSUE == SAK-* ]] || [[ $ISSUE == SAM-* ]] || [[ $ISSUE == KNL-* ]];
then
if $(curl -v --silent https://jira.sakaiproject.org/rest/api/2/issue/$ISSUE?fields=status\&fields=customfield_11676 2>&1 | grep -qE $CHECKST)
then
echo "$SEPARATOR $ISSUE: 11.x $SEPARATOREND"
MERGE=11
else
echo "$SEPARATOR $ISSUE: Not ready for 11.x $SEPARATOREND"
MERGE=N
fi
else
echo "$SEPARATOR NONJIRA: $ISSUE $SEPARATOREND"
MERGE=N
fi
fi
fi
CNT=$[CNT + 1]
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment