Move scripts to separate directory

This commit is contained in:
2018-02-06 11:53:51 +01:00
parent f21238db89
commit d29b955a5e
7 changed files with 0 additions and 0 deletions

49
src/mirror-main-repo Executable file
View File

@@ -0,0 +1,49 @@
#!/bin/bash
#
# Just mirror (clone or fetch) specified git repository
# - no other mess (eg submodules, just clean mirror)
#
# Usage:
# mirror-main-repo <url>
# Unofficial strict mode
set -euo pipefail
IFS=$'\n\t'
source $(dirname $(realpath $0))/gen-mirror-path
function updateOrCreate(){
url=$1
repodir=$(getRepoPath $url)
if [ ! -d $repodir ]
then
echo "Clone of $url"
git clone --bare --mirror $url $repodir
else
cd $repodir
echo "Update of $url"
git fetch --prune
fi
# tags
}
function getLastCommit(){
url=$1
repodir=$(getRepoPath $url)
if [ -d $repodir ]
then
cd $repodir
git --no-pager log --full-history --all -1 --pretty=format:"%H%n"
else
echo '-'
fi
}
oldPwd=$(pwd)
updateOrCreate $1
cd $oldPwd