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
# mfadd
4
#
5
# Add a remote and fetch it. Optionally copy a branch.
6
#
7
# Example: mfadd thinkyhead:patch-1 copy_of_patch-1
8
#
9
 
10
[[ $# > 0 && $# < 3 && $1 != "-h" && $1 != "--help" ]] || { echo "Usage: `basename $0` (user | ref copyname)" 1>&2 ; exit 1; }
11
 
12
# If a colon is included, split the parts
13
if [[ $1 =~ ":" ]]; then
14
  IFS=':' read -a DATA <<< "$1"
15
  USER=${DATA[0]}
16
  BRANCH=${DATA[1]}
17
  NAME=$2
18
else
19
  USER=$1
20
fi
21
 
22
MFINFO=$(mfinfo) || exit 1
23
IFS=' ' read -a INFO <<< "$MFINFO"
24
REPO=${INFO[2]}
25
 
26
set -e
27
 
28
echo "Adding and fetching $USER..."
29
git remote add "$USER" "git@github.com:$USER/$REPO.git" >/dev/null 2>&1 || echo "Remote exists."
30
git fetch "$USER"
31
 
32
[[ ! -z "$BRANCH" && ! -z "$NAME" ]] && git checkout $USER/$BRANCH -b $NAME