Working copy of script

This commit is contained in:
2018-02-05 15:47:39 +01:00
commit 73bfa09839
7 changed files with 424 additions and 0 deletions

42
gen-mirror-path Executable file
View File

@@ -0,0 +1,42 @@
#!/bin/bash
source $(dirname $(realpath $0))/config
function getRepoUniq(){
base=$(basename $1 .git)
rest=$(dirname $1)
# .git (working repo)
if [ "$base" == ".git" ]
then
base=$(basename $rest)
rest=$(dirname $rest)
fi
# extract username - or path
namespace=$(basename $rest)
# solve ssh domain:namespace/repo.git
if [[ "$namespace" == *:* ]]
then
namespace=$(echo $namespace | cut -d':' -f2)
fi
csum=$(echo $1 | cksum | cut -d' ' -f1)
echo ${namespace}_${base}_${csum}
}
function getRepoPath(){
uniq=$(getRepoUniq $1)
echo $cfgMirrorPath/$uniq.git
}
function getRepoCache(){
uniq=$(getRepoUniq $1)
echo $cfgCachePath/$uniq
}
# it the script is not sourced
if [[ ! "${BASH_SOURCE[0]}" != "${0}" ]]
then
getRepoPath $1
fi