blob: 6c8e499036742ccf34d7673c94f4d0cd45c4cf6d (
plain)
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
62
63
64
65
66
67
68
69
|
#!/bin/bash
set -x
# use a mandatory first arg of "run" when not running as GIT_SSH
if [ "run" != "$1" ]; then
# just exec ssh with some extra arguments
exec ssh \
-i "$git_publish_keyfile" \
-o "StrictHostKeyChecking no" \
"$@"
fi
# running as git push script
export GIT_SSH="$0"
# set some defaults if not already set
#
git_tag="" # if set then pushing tag instead of branch
git_force=""
# parse commandline arguments
#
shift # drop the mandatory "run" argument
while (( $# > 0 )) ; do
case $1 in
--local_branch)
git_local_branch=$2
shift
;;
--remote_branch)
git_remote_branch=$2
shift
;;
--remote_repo)
git_remote_repo=$2
shift
;;
--tag)
git_tag=$2
shift
;;
-f|--force)
git_force="-f"
;;
--keyfile)
export git_publish_keyfile=$2
shift
;;
esac
shift
done
[ -n "$git_publish_keyfile" ] || { echo "--keyfile KEYFILENAME is required"; exit 1; }
remote_name=remote_random_$RANDOM
git remote add $remote_name $git_remote_branch
if [ $git_tag ]
then
git push $git_force $git_remote_repo $git_tag
else
git push $git_force $git_remote_repo $git_local_branch:refs/heads/$git_remote_branch
fi
# cleanup
git remote rm $remote_name
exit 0
|