43 lines
756 B
Plaintext
43 lines
756 B
Plaintext
|
#!/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
|
||
|
|
||
|
|