Subversion Repositories MK-Marlin

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 ron 1
#!/usr/bin/env bash
2
#
3
# mfnew
4
#
5
# Create a new branch from the default target with the given name
6
#
7
 
8
usage() {
9
  echo "Usage: `basename $0` [1|2] [name]" 1>&2
10
}
11
 
12
[[ $# < 3 && $1 != "-h" && $1 != "--help" ]] || { usage; exit 1; }
13
 
14
MFINFO=$(mfinfo "$@") || exit 1
15
IFS=' ' read -a INFO <<< "$MFINFO"
16
TARG=${INFO[3]}
17
BRANCH=pr_for_$TARG-$(date +"%G-%m-%d_%H.%M.%S")
18
 
19
# BRANCH can be given as the last argument
20
case "$#" in
21
  1 ) case "$1" in
22
        1|2) ;;
23
        *) BRANCH=$1 ;;
24
      esac
25
      ;;
26
  2 ) case "$1" in
27
        1|2) BRANCH=$2 ;;
28
        *) usage ; exit 1 ;;
29
      esac
30
      ;;
31
esac
32
 
33
git fetch upstream
34
git checkout --no-track upstream/$TARG -b $BRANCH