From ff1e90982aff1c9113f61d00da71cf4ac79ebfd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Val=C3=AD=C4=8Dek?= Date: Wed, 3 Aug 2022 00:05:27 +0200 Subject: [PATCH] Cleanup old scripts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Václav Valíček --- old/checker/run-checker | 16 ------ old/src/mirror-recursive | 103 +-------------------------------------- 2 files changed, 1 insertion(+), 118 deletions(-) diff --git a/old/checker/run-checker b/old/checker/run-checker index de2517d..ce6b219 100755 --- a/old/checker/run-checker +++ b/old/checker/run-checker @@ -2,25 +2,9 @@ set -euo pipefail IFS=$'\n\t' -# source libs -mydir=$(dirname $(realpath $0)) - - -source $mydir/detector-lib-cfg - -# check and clone repo -submodules=${cloner_submodules:-0} -depth=${cloner_submodule_depth:-} prepareGitAuth $CONFIG_DIR -# without submodule support -if [ ! "x$submodules" = "x1" ] -then - mirror-main-repo $repo -else - mirror-recursive $repo $depth -fi # if detector is not enabled, quit quietly if ! detectorRunCapable diff --git a/old/src/mirror-recursive b/old/src/mirror-recursive index 372e102..019e60f 100755 --- a/old/src/mirror-recursive +++ b/old/src/mirror-recursive @@ -1,5 +1,5 @@ #!/bin/bash -# +# # Mirror git repository with submodules - recursively # # Usage: @@ -9,105 +9,4 @@ set -euo pipefail IFS=$'\n\t' -# Scratch - temp -tmpdir=$(mktemp -d -t mirror-recursive-XXXXXXX) -function finish { - rm -rf "$tmpdir" -} -trap finish EXIT - -source $(dirname $(realpath $0))/config -source $(dirname $(realpath $0))/gen-mirror-path - - -function progress(){ - local progress=${1:-100} - echo -n "..$progress%" - if [ $progress -eq 100 ] - then - echo - fi -} - -function submoduleDiscovery(){ - # main parameters - local repo=$1 - local gitdir=$(getRepoPath $repo) - # depth (empty or prefixed from main script) - local depth=${2:-} - # temporary path - local tmpname=$(getRepoUniq $repo) - tmpname=$tmpdir/$tmpname - local tmpCommitList=$tmpname.commits - local tmpSubmoduleList=$tmpname.submodules - # cache paths - local cachePath=$(getRepoCache $repo) - local cacheCommits=$cachePath/commits-checked - local cacheSubmodules=$cachePath/submodules-checked - - # check, if cache exists - [ -d $cachePath ] || mkdir -p $cachePath - [ -f $cacheCommits ] || touch $cacheCommits - [ -f $cacheSubmodules ] || touch $cacheSubmodules - - # avoid recursion - if commit list exists - # there was activity with this run recently - if [ ! -f $tmpCommitList ] - then - - # cache submodules reuse - cat $cacheSubmodules > $tmpSubmoduleList - - echo -n "Discovering submodules of $repo.. " - git --git-dir $gitdir log --all $depth --format="%H" | sort > $tmpCommitList - - # check against cache - echo -n "cache check.." - comm -13 $cacheCommits $tmpCommitList > $tmpname - mv $tmpname $tmpCommitList - - local commits=$(wc -l $tmpCommitList | cut -d' ' -f1) - echo -n "$commits commits" - # this can take long time... - local processed=0 - local nextStamp=$(($(date +"%s") + 3)) - while read -r line || [[ -n "$line" ]] - do - submodule-describe $gitdir $line | cut -f 3 >> $tmpSubmoduleList - # progress indication - processed=$(($processed + 1)) - if [ $(date +"%s") -gt $nextStamp ] - then - progress $((100*$processed/$commits)) - nextStamp=$(($nextStamp + 3)) - fi - done < $tmpCommitList - # finish the bar - progress - - # archive to cache - cat $tmpCommitList $cacheCommits > $tmpname - sort $tmpname > $cacheCommits - sort $tmpSubmoduleList | uniq > $tmpname - cat $tmpname > $cacheSubmodules - - # Recursion++ - while read -r submodule || [[ -n "$submodule" ]] - do - mirror-main-repo $submodule - submoduleDiscovery $submodule $depth - done < $cacheSubmodules - fi - -} - -# main repo -mainrepo=$1 -depth=${2:-} - -[ -n "$depth" ] && depth="-$depth" - -# Make first mirror -mirror-main-repo $mainrepo -submoduleDiscovery $mainrepo $depth