+
+
+ Mike Gerwitz's Thoughts and Ramblings
+
+
+ Mike Gerwitz's Thoughts and Ramblings
+EOH
+
+
+prevdate=
+lastts=
+firstyear=
+lastyear=
+lasthash=
+
+# generate index
+while read hash commit ts id subject; do
+ echo "Found $commit: $subject" >&2
+
+ dateout="$( printf "%(%Y-%m-%d)T" "$ts" )"
+ dategroup="${dateout%-*}"
+ day="${dateout##*-}"
+ month="$( printf "%(%m)T" "$ts" )"
+ year="${dateout%%-*}"
+
+ # commits are ordered by date desc
+ lasthash="${lasthash:-$hash}"
+ lastts="${lastts:-$ts}"
+ lastyear="${lastyear:-$year}"
+ firstyear="$year"
+
+ pagefile="$year/$month/$id.html"
+ fmtsubject="$( ./msgfmt < <( echo "$subject"; echo ) )"
+
+ [ "$prevdate" == "$dategroup" ] || {
+ echo "$dategroup
"
+ }
+
+ printf '' \
+ "$day" "$pagefile" "$fmtsubject"
+
+ prevdate="$dategroup"
+
+ # create the containing directory (if it does not yet exist and then generate
+ # the commit page
+ mkdir -p "$( dirname "$pagefile" )" \
+ && (
+ # make the majority of the data available as environment variables (for
+ # convenience), lowercase so as not to be conflict with conventional
+ # environment variables
+ export hash commit id subject="$fmtsubject" timestamp="$ts"
+ export dategroup month day year
+
+ # invoke template
+ "$repotype"/commit2html "$commit" | ./tpl/commit.sh
+ ) > "$path_out/$pagefile"
+done
+
+yearrange="$firstyear"
+if [ "$lastyear" -gt "$firstyear" ]; then
+ yearrange="$firstyear–$lastyear"
+fi
+
+cat <
+
+
+
+EOF
diff --git a/repo2html b/repo2html
index dcb0ca6..35e6fac 100755
--- a/repo2html
+++ b/repo2html
@@ -1,6 +1,6 @@
#!/bin/bash
#
-# Generates HTML from repository commit messages (currently Git only)
+# Detects repository VCS and begins VCS-specific processing
#
# Copyright (C) 2012 Mike Gerwitz
#
@@ -20,83 +20,21 @@
# along with this program. If not, see .
# #
+# repository detection
+repotype=
+if repodir="$( git rev-parse --git-dir 2>/dev/null )"; then
+ # use absolute path for git directory
+ export GIT_DIR="$( cd $repodir && pwd )"
+ repotype=git
+else
+ # contribute!
+ echo "fatal: only git repositories are currently supported" >&2
+ exit 128
+fi
+
path_out="$( pwd )"
path="$( dirname "$0" )"
cd "$path"
-export GIT_DIR="$path_out/.git"
-
-cat <
-
-
- Mike Gerwitz's Thoughts and Ramblings
-
-
- Mike Gerwitz's Thoughts and Ramblings
-EOH
-
-
-lastdate=
-firstyear=
-lastyear=
-
-# generate index
-while read hash commit ts id subject; do
- echo "Found $commit: $subject" >&2
-
- dateout="$( printf "%(%Y-%m-%d)T" "$ts" )"
- dategroup="${dateout%-*}"
- day="${dateout##*-}"
- month="$( printf "%(%m)T" "$ts" )"
- year="${dateout%%-*}"
-
- # commits are ordered by date desc
- lastyear="${lastyear:-$year}"
- firstyear="$year"
-
- pagefile="$year/$month/$id.html"
- fmtsubject="$( ./msgfmt < <( echo "$subject"; echo ) )"
-
- [ "$lastdate" == "$dategroup" ] || {
- echo "$dategroup
"
- }
-
- printf '' \
- "$day" "$pagefile" "$fmtsubject"
-
- lastdate="$dategroup"
-
- # create the containing directory (if it does not yet exist and then generate
- # the commit page
- mkdir -p "$( dirname "$pagefile" )" \
- && (
- # make the majority of the data available as environment variables (for
- # convenience), lowercase so as not to be conflict with conventional
- # environment variables
- export hash commit id subject="$fmtsubject" timestamp="$ts"
- export dategroup month day year
-
- # invoke template
- ./hash2html "$commit" | ./tpl/commit.sh
- ) > "$path_out/$pagefile"
-done < <(
- git log --pretty='format:%H %h %at %f %s' && echo
-)
-
-
-yearrange="$firstyear"
-if [ "$lastyear" -gt "$firstyear" ]; then
- yearrange="$firstyear–$lastyear"
-fi
-
-cat <
-
-
-
-EOF
+# pass commit list to the processor
+"$repotype"/list | ./processor "$repotype" "$path_out"