]> git.armaanb.net Git - bin.git/blobdiff - git-mirror
git-mirror: remove css copying
[bin.git] / git-mirror
index bdb22f22c2435b011a11127f363fbb3882320567..23a89407c03d69f3ee042acfa9fc5ae96858e8ad 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/sh
+#!/usr/bin/env sh
 # Mirror some Git repos
 
 usage() {
@@ -14,50 +14,54 @@ usage() {
 run() {
   [ -z ${3} ] && echo "not enough arguments" && exit 1
   [ -z $(which stagit) ] && echo "please install stagit" && exit 1
+  [ -z $(which minify) ] && echo "please install minify" && exit 1
 
   cd ${1}
 
   [ -d ${3} ] || mkdir ${3}
-  stagit-index ./* > ${3}/index.html
-  cp /usr/share/doc/stagit/style.css ${3}
+  cd ${3} && stagit-index ${1}/*
 
   while :; do
-    find ${1} -maxdepth 2 -name '*.git' | \
+    find "$1" -name '*.git' -type d | \
       while read dir; do
         newdir=${3}/$(basename ${dir} .git)
         [ -d ${newdir} ] || mkdir ${newdir}
         cd ${newdir}
         stagit ${dir}
-        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}
+        find . -type f \( -name '*.html' -or -name '*.xml' \) | \
+          while read i ; do
+            minify ${i} > ${i}.tmp
+            mv ${i}.tmp ${i}
+          done
+          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