forked from slobobaby/git_filter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpush_clean_repos
executable file
·45 lines (37 loc) · 1023 Bytes
/
push_clean_repos
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
#!/bin/sh
#
# Copyright (C) 2014 Brian Murphy <[email protected]>
#
# This file is part of git_filter, distributed under the GNU GPL v2.
# For full terms see the included COPYING file.
#
syntax()
{
echo "syntax: $0 CONFIGFILE [<output prefix>]"
exit 1
}
if [ "set${1}" = "set" ]; then
syntax
fi
if [ "set${2}" != "set" ]; then
OUTPUT_PREFIX=${2}
fi
CONFIG_FILE=$1
REPO=`awk '/^REPO: / {print $2}' $CONFIG_FILE |head -n 1`
NAMES=`awk '/^FILT: / {print $2}' $CONFIG_FILE`
TPFX=`awk '/^TPFX: / {print $2}' $CONFIG_FILE`
# try and figure out if the repository is bare or not
REPO_GIT=$REPO/.git
if [ ! -d $REPO_GIT ]; then
REPO_GIT=$REPO
fi
# repack the source repository to ensure it is compact
# speeds up the push later
git --git-dir=$REPO_GIT repack -ad
for name in $NAMES; do
newbranch=$TPFX$name
newrepo=${OUTPUT_PREFIX}${newbranch}.git
# create the git repository if it does not exist
git --git-dir=$newrepo init
git --git-dir=$REPO_GIT push $newrepo $newbranch:master
done