From b18ff3cb50569f25c334f412030972b4bf159b46 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Fri, 15 Mar 2024 19:16:11 +0100 Subject: Add git2redcrew and git2private to the repo. --- README.md | 4 ++++ git2private | 32 ++++++++++++++++++++++++++++++++ git2redcrew | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 94 insertions(+) create mode 100755 git2private create mode 100755 git2redcrew diff --git a/README.md b/README.md index c45f7c1..ab7fc9b 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,10 @@ 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: +---------------------------- + +Create copy of the current repo (or named repo) on private server. ---- diff --git a/git2private b/git2private new file mode 100755 index 0000000..87e10f6 --- /dev/null +++ b/git2private @@ -0,0 +1,32 @@ +#!/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 ' + 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 new file mode 100755 index 0000000..0648f5c --- /dev/null +++ b/git2redcrew @@ -0,0 +1,58 @@ +#!/bin/sh + +set -uex + +SUBDIR="" + +while getopts ":d:" opt; do + case $opt in + d) + SUBDIR="$OPTARG" + ;; + \?) + echo "Invalid option: -$OPTARG" + exit 1 + ;; + :) + echo "Option -$OPTARG requires an argument." + exit 1 + ;; + esac +done + +# Shift past the last option parsed by getopts +shift $((OPTIND-1)) + +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 ' + git remote rm origin || /bin/true +) + +rsync -avz "${GITDIR}" redcrew:/srv/git/ +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" +# if git remote show gitlab >/dev/null 2>&1 ; then +# git remote remove gitlab +# fi +git remote update +git push --all -u myrepo -- cgit