-
Notifications
You must be signed in to change notification settings - Fork 14
/
make_branches
executable file
·65 lines (59 loc) · 2.46 KB
/
make_branches
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
#!/bin/bash
# This is a work in progress - does not yet do all that needs to be done
if [ "$1" != "" ]; then
filter=$1
else
filter=.
fi
remote=$(git remote -v | grep fetch | awk '{print $2}')
case $remote in
*github.com*)
remote_ssh=git@github.com:MarkEWaite/jenkins-bugs.git
remote_https=https://github.com/MarkEWaite/jenkins-bugs
;;
*gitea*)
remote_ssh=git@gitea-server.markwaite.net:mwaite/jenkins-bugs.git
remote_https=https://home.markwaite.net/gitea/mwaite/jenkins-bugs.git
;;
*)
echo "Remote not supported by this script"
exit 1
;;
esac
echo remote_ssh is $remote_ssh
echo remote_https is $remote_https
for keyword in JENKINS MHA SECURITY ZD; do
for origin in $(git branch -a | grep $filter | grep origin.*${keyword} | sed 's!remotes/!!g'); do
bug=$(echo $origin | sed -e "s!.*${keyword}!${keyword}!g" -e 's!/.*$!!g')
branch=$(echo $origin | sed 's!origin/!!g')
dir=$(echo $origin | sed -e "s!.*${keyword}!${keyword}!g" -e 's!/!-!g')
[ -d ../$dir ] && continue
echo Cloning for bug $bug, branch $branch, dir $dir
( cd .. && \
git clone --branch $branch \
--single-branch \
--no-tags \
--reference /var/cache/git/mwaite/bugs/jenkins-bugs.git \
$remote_https \
$dir )
echo Cloned for bug $bug, branch $branch, dir $dir
( cd ../$dir && \
if [[ $remote =~ "github.com" ]]; then
git remote add gitea-server git@gitea-server.markwaite.net:mwaite/jenkins-bugs.git && \
git config remote.gitea-server.fetch $(git config --get remote.origin.fetch | sed 's/origin/gitea-server/g')
fi
if [[ $remote =~ "gitea-server" ]]; then
git remote add github git@github.com:MarkEWaite/jenkins-bugs.git && \
git config remote.github.fetch $(git config --get remote.origin.fetch | sed 's/origin/github/g')
fi
git config remote.origin.pushurl $remote_ssh &&
git remote add cache mwaite@git.markwaite.net:git/bare/bugs/jenkins-bugs.git && \
git config remote.cache.fetch $(git config --get remote.origin.fetch | sed 's/origin/cache/g') && \
git remote add bare /var/cache/git/mwaite/bugs/jenkins-bugs.git && \
git config remote.bare.fetch $(git config --get remote.origin.fetch | sed 's/origin/bare/g') && \
git push cache && \
git push bare && \
git pull --no-tags --all --prune )
echo Configured for bug $bug, branch $branch, dir $dir
done
done