-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathencrypt.sh
More file actions
executable file
·42 lines (34 loc) · 1.16 KB
/
encrypt.sh
File metadata and controls
executable file
·42 lines (34 loc) · 1.16 KB
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
#!/bin/bash
if [ -z "${1}" ]; then
echo "You must specify a remote source, for example:"
echo "gcrypt encrypt git@github.com:user/repo.git"
exit 1
fi
PREFIX="[GCRYPT]"
SRC_REPO=$1
BARE_REPO="/tmp/gcrypt-bare.git"
DEST_REPO="/tmp/gcrypt-dest.git"
echo "$PREFIX clone source"
git clone $SRC_REPO $DEST_REPO || exit 1
cd $DEST_REPO
echo "$PREFIX create bare repo"
git init --bare $BARE_REPO
echo "$PREFIX encrypt source and move to bare repo"
for branch in `git branch -a | grep remotes | grep -v HEAD | grep -v master `; do
git branch --track ${branch#remotes/origin/} $branch
done
git remote add encrypting gcrypt::$BARE_REPO
git push --all --force encrypting
git push --tags encrypting
echo "$PREFIX overwrite remote source"
cd $BARE_REPO
git remote add origin $SRC_REPO
git push --all --force
echo "$PREFIX back to source and delete other remote branches"
cd $DEST_REPO
git branch -r | grep 'origin' | grep -v 'master$' | grep -v HEAD | cut -d/ -f2- | while read line; do git push origin :heads/$line; done;
git tag | xargs -L 1 | xargs git push origin --delete
echo "$PREFIX delete temp repos"
rm -rf $BARE_REPO
rm -rf $DEST_REPO
echo "Temporal repositories deleted"