Skip to content

Instantly share code, notes, and snippets.

@alexanderjeurissen
Last active January 28, 2017 13:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexanderjeurissen/d39647d29219feebb3ba069c754d5da7 to your computer and use it in GitHub Desktop.
Save alexanderjeurissen/d39647d29219feebb3ba069c754d5da7 to your computer and use it in GitHub Desktop.
Fuzzy select a Arcanist differential to either browse or land
browse() {
case $1 in
acc)
diffs=`arc list | grep 'Accepted' | egrep -o 'D\d+: .*'`
;;
rev)
diffs=`arc list | grep 'Needs Review' | egrep -o 'D\d+: .*'`
;;
req)
diffs=`arc list | grep 'Needs Revision' | egrep -o 'D\d+: .*'`
;;
*)
echo "Usage: $0 {acc||rev|req|cha}"
return 1
esac
if [ -z $diffs ]; then
echo "no \`$1\` diffs available for browsing"
return 1
fi
chosen_diff=`echo $diffs | fzf | egrep -o 'D\d{5}'`
if [ -z $chosen_diff ]; then
echo "operation cancelled"
return 1
fi
arc browse $chosen_diff
}
land() {
diffs=`arc list | grep 'Accepted' | egrep -o 'D\d+: .*'`
if [ -z $diffs ]; then
echo "no diffs available for landing"
return 1
fi
chosen_diff=`echo $diffs | fzf | egrep -o 'D\d{5}'`
if [ -z $chosen_diff ]; then
echo "operation cancelled"
return 1
fi
stash # stash current working directory, this a shell alias of mine. You can replace this with git stash -u
# TODO: add item to todolist to continue working on the just stashed changes
gco develop
arc patch $chosen_diff
# confirm landing this patch
read -p "Continue with landing (y/n)?" choice
case "$choice" in
y|Y ) arc land $chosen_diff;;
n|N ) echo "operation cancelled";;
* ) echo "invalid choice, please provide (y/n)";;
esac
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment