From 6798937faee881869fa22a839d8db26aa7ff2b40 Mon Sep 17 00:00:00 2001 From: Armaan Bhojwani Date: Mon, 5 Apr 2021 10:36:49 -0400 Subject: [PATCH] git-mirror: update for loop style --- git-mirror | 67 +++++++++++++++++++++++++++--------------------------- 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/git-mirror b/git-mirror index 6457db6..0b3901f 100755 --- a/git-mirror +++ b/git-mirror @@ -1,4 +1,4 @@ -#!/usr/bin/sh +#!/usr/bin/env sh # Mirror some Git repos usage() { @@ -19,11 +19,12 @@ run() { cd ${1} [ -d ${3} ] || mkdir ${3} - cd ${3} && stagit-index + cd ${3} && stagit-index ${1}/* cp /usr/share/doc/stagit/style.css ${3} while :; do - for dir in "${1}/*.git"; do + find "$1" -name '*.git' -type d | \ + while read dir; do newdir=${3}/$(basename ${dir} .git) [ -d ${newdir} ] || mkdir ${newdir} cd ${newdir} @@ -33,36 +34,36 @@ run() { minify ${i} > ${i}.tmp mv ${i}.tmp ${i} done - cp /usr/share/doc/stagit/style.css . - git -C ${dir} fetch --tags - echo $(date -Iseconds) ' | ' ${dir} | tee -a ${2} - echo $(tail -n 1500 ${2}) > ${2} + cp /usr/share/doc/stagit/style.css . + git -C ${dir} fetch --tags + echo $(date -Iseconds) ' | ' ${dir} | tee -a ${2} + echo $(tail -n 1500 ${2}) > ${2} + done + sleep 600 done - sleep 600 - done -} + } -gen_url() { - find ${1} -maxdepth 2 -name '*.git' | \ - while read dir; do - $(git -C $dir remote get-url origin) > $dir/url - done -} + gen_url() { + find ${1} -maxdepth 2 -name '*.git' | \ + while read dir; do + $(git -C $dir remote get-url origin) > $dir/url + done + } -case ${1} in - -h | --help | help) - usage - ;; - run) - shift 1 - run $@ - ;; - gen-url) - shift 1 - gen_url $@ - ;; - *) - usage - exit 1 - ;; -esac + case ${1} in + -h | --help | help) + usage + ;; + run) + shift 1 + run $@ + ;; + gen-url) + shift 1 + gen_url $@ + ;; + *) + usage + exit 1 + ;; + esac -- 2.39.2