aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md4
-rwxr-xr-xgit2private32
-rwxr-xr-xgit2redcrew.sh (renamed from git2redcrew)28
3 files changed, 24 insertions, 40 deletions
diff --git a/README.md b/README.md
index ab7fc9b..859abb6 100644
--- a/README.md
+++ b/README.md
@@ -46,8 +46,8 @@ git-svn(1) doesn’t really work with tags, it just creates
branches called like tags. This script makes tags out of those
branches.
-git2redcrew and git2private:
-----------------------------
+git2redcrew:
+------------
Create copy of the current repo (or named repo) on private server.
diff --git a/git2private b/git2private
deleted file mode 100755
index 87e10f6..0000000
--- a/git2private
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/bin/sh
-
-set -eux
-
-if [ -d .git ] ; then
- git gc --aggressive --prune=now
- REPO="$(basename $(git rev-parse --show-toplevel))"
- cd ..
-else
- [ -n "$1" ] || exit 1
- REPO="$1"
- (cd "$REPO"
- git gc --aggressive --prune=now
- )
-fi
-GITDIR="$(readlink -f "${REPO}").git"
-git clone --bare "$REPO" "${GITDIR}"
-(cd "${GITDIR}"
- # shellcheck disable=SC3045
- read -r -e -p "Describe the repository:" DESC
- echo "$DESC" >description
- touch git-daemon-export-ok
- git config --add gitweb.owner 'Matěj Cepl <mcepl@cepl.eu>'
- git remote rm origin || /bin/true
-)
-
-rsync -avz "${GITDIR}" redcrew:private_git/
-rm -rf "${GITDIR}"
-cd "$REPO"
-git remote add myrepo "redcrew:private_git/${REPO}.git"
-git remote update
-git push --all -u myrepo
diff --git a/git2redcrew b/git2redcrew.sh
index 0648f5c..964e6e1 100755
--- a/git2redcrew
+++ b/git2redcrew.sh
@@ -1,13 +1,19 @@
#!/bin/sh
-set -uex
+set -ue
SUBDIR=""
+PRIVATE=0
-while getopts ":d:" opt; do
+REMHOST="redcrew"
+
+while getopts ":d:p" opt; do
case $opt in
d)
- SUBDIR="$OPTARG"
+ SUBDIR="/${OPTARG}"
+ ;;
+ p)
+ PRIVATE=1
;;
\?)
echo "Invalid option: -$OPTARG"
@@ -46,11 +52,21 @@ git clone --bare "$REPO" "${GITDIR}"
git remote rm origin || /bin/true
)
-rsync -avz "${GITDIR}" redcrew:/srv/git/
+if [ $PRIVATE -eq 1 ] ; then
+ TARGET="private_git${SUBDIR}"
+ URL_BASE="${REMHOST}:${TARGET}"
+else
+ TARGET="/srv/git${SUBDIR}"
+ URL_BASE="https://git.cepl.eu/cgit${SUBDIR}"
+fi
+
+rsync -avz "${GITDIR}" "${REMHOST}:${TARGET}/"
rm -rf "${GITDIR}"
cd "$REPO"
-git remote add myrepo "https://git.cepl.eu/cgit/${REPO}"
-git remote set-url --push myrepo "redcrew:/srv/git/${REPO}.git"
+git remote add myrepo "${URL_BASE}/${REPO}"
+if [ $PRIVATE -ne 1 ] ; then
+ git remote set-url --push myrepo "${REMHOST}:${TARGET}/${REPO}.git"
+fi
# if git remote show gitlab >/dev/null 2>&1 ; then
# git remote remove gitlab
# fi