-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpush.sh
executable file
·61 lines (55 loc) · 1.13 KB
/
push.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#! /bin/bash
usedBranch=""
branches=`git branch`
oldIFS="$IFS"
IFS='
'
lines=( $branches )
IFS="$oldIFS"
branch=""
for line in "${lines[@]}"
do
isCurrentBranch=false
#t=`expr substr "$line" 1 1`
t=${line:0:1}
if [ "$t" = "*" ]
then
isCurrentBranch=true
fi
#branch=`expr substr "$line" 3 "${#line}"`
branch=${line:2}
if test -z "$1"
then
if [ "$isCurrentBranch" = true ]
then
usedBranch="$branch"
break
fi
else
if [ "$1" = "$branch" ]
then
usedBranch="$branch"
break
fi
fi
done
if test -z "$usedBranch"
then
if test -z "$1"
then
echo "Push failed: working branch was not found, are you under gir repository?"
echo "Usage: push [branch name]"
exit 1
else
echo "Push failed: specified branch is not valid - $1"
echo "Usage: push [branch name]"
exit 1
fi
fi
repositories=`git remote`
for repository in ${repositories[@]}
do
echo ">>> push change to $repository for branch $usedBranch <<<"
git push $repository $usedBranch
done
exit 0