]> git.armaanb.net Git - bin.git/commitdiff
git-mirror: update for loop style
authorArmaan Bhojwani <me@armaanb.net>
Mon, 5 Apr 2021 14:36:49 +0000 (10:36 -0400)
committerArmaan Bhojwani <me@armaanb.net>
Mon, 5 Apr 2021 14:51:30 +0000 (10:51 -0400)
git-mirror

index 6457db6c27eeb29bc672bcff33aa5f1db3f240c8..0b3901fc3f5e45c9051498a56de22f52baebec7b 100755 (executable)
@@ -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