Commit 9898062b by John Jarvis

adds a utility script to get rc branches

parent f1407cd5
#!/bin/bash
usage() {
prog=$(basename "$0")
cat<<EOF
This will clone a repo and look for release
candidate branches that will be returned as
a sorted list in json to be
parsed by the dynamic choice jenkins plugin
Usage: $prog
-v add verbosity (set -x)
-n echo what will be done
-h this
-r repo to look in
-f filter string for branch list
Example: $prog -r https://github.com/edx/edx-platform -f "rc/"
EOF
}
while getopts "vnhr:f:" opt; do
case $opt in
v)
set -x
shift
;;
h)
usage
exit 0
;;
n)
noop="echo Would have run: "
shift
;;
r)
repo=$OPTARG
;;
f)
filter=$OPTARG
;;
esac
done
if [[ -z $repo || -z $filter ]]; then
echo 'Need to specify a filter and a repo'
usage
exit 1
fi
repo_basename=$(basename "$repo")
cd /var/tmp
if [[ ! -d $repo_basename ]]; then
$noop git clone "$repo" "$repo_basename" --mirror
else
$noop cd "/var/tmp/$repo_basename"
$noop git fetch
fi
$noop cd "/var/tmp/$repo_basename"
if [[ -z $noop ]]; then
python -c 'import sys, json; print json.dumps([line.lstrip().rstrip() for line in sys.stdin])' < <(git branch -a | grep "$filter" | sort -r | head )
else
echo "Would have checked for branches using filter $filter"
fi
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment