You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
673 B
Plaintext
35 lines
673 B
Plaintext
9 years ago
|
#!/usr/bin/env bash
|
||
|
#
|
||
|
# mfnew
|
||
|
#
|
||
8 years ago
|
# Create a new branch from the default target with the given name
|
||
9 years ago
|
#
|
||
|
|
||
7 years ago
|
usage() {
|
||
5 years ago
|
echo "usage: `basename $0` [1|2|3] [name]" 1>&2
|
||
7 years ago
|
}
|
||
8 years ago
|
|
||
7 years ago
|
[[ $# < 3 && $1 != "-h" && $1 != "--help" ]] || { usage; exit 1; }
|
||
7 years ago
|
|
||
|
MFINFO=$(mfinfo "$@") || exit 1
|
||
9 years ago
|
IFS=' ' read -a INFO <<< "$MFINFO"
|
||
|
TARG=${INFO[3]}
|
||
7 years ago
|
BRANCH=pr_for_$TARG-$(date +"%G-%m-%d_%H.%M.%S")
|
||
9 years ago
|
|
||
7 years ago
|
# BRANCH can be given as the last argument
|
||
9 years ago
|
case "$#" in
|
||
7 years ago
|
1 ) case "$1" in
|
||
5 years ago
|
1|2|3) ;;
|
||
7 years ago
|
*) BRANCH=$1 ;;
|
||
|
esac
|
||
|
;;
|
||
|
2 ) case "$1" in
|
||
5 years ago
|
1|2|3) BRANCH=$2 ;;
|
||
7 years ago
|
*) usage ; exit 1 ;;
|
||
|
esac
|
||
|
;;
|
||
9 years ago
|
esac
|
||
|
|
||
8 years ago
|
git fetch upstream
|
||
7 years ago
|
git checkout --no-track upstream/$TARG -b $BRANCH
|