forked from dustinkirkland/bikeshed
-
Notifications
You must be signed in to change notification settings - Fork 2
/
multi-push
executable file
·47 lines (43 loc) · 1.6 KB
/
multi-push
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
#!/bin/sh
#
# multi-push - push a bzr branch to both Launchpad and Github
# Copyright (C) Dustin Kirkland <[email protected]>
#
# Authors: Dustin Kirkland <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set -e
# Ensure that we're in a bzr branch
# TODO: Currently LP is master, GH is slave
# TODO: Should support both directions
[ -d ${PWD}/.bzr ] || exit 1
echo "INFO: bzr exists"
bzr push "$@"
# Handle bootstrapping of a new branch
if [ $(basename "$0") = "multi-push-init" ]; then
mkdir -p ${PWD}.git
OLDPWD="${PWD}"
cd ${PWD}.git
git init .
# export + import + push
bzr fast-export --export-marks=../.marks.bzr ${OLDPWD} | git fast-import --quiet --export-marks=../.marks.git
git remote add origin [email protected]:${GITHUB_ID}/$(basename ${OLDPWD}).git
git push -u origin master
elif [ -d ${PWD}.git ]; then
echo "INFO: git exists"
OLDPWD="${PWD}"
cd ${PWD}.git
# Export + import + push
bzr fast-export --export-marks=../.marks.bzr ${OLDPWD} | git fast-import --quiet --export-marks=../.marks.git
git push
fi