Added cref-errlog to post-process cref errors rather than priming the hashcache
This is more performant, contains additional logging and will properly output invalid crefs.master
parent
6f9001740c
commit
3cec847866
|
@ -28,6 +28,6 @@ msgfmt="${msgfmt:-./msgfmt}"
|
||||||
echo -n '<p>'
|
echo -n '<p>'
|
||||||
|
|
||||||
git show --pretty=format:%b "$commit" \
|
git show --pretty=format:%b "$commit" \
|
||||||
| "$msgfmt"
|
| "$msgfmt" "$commit"
|
||||||
|
|
||||||
echo '</p>'
|
echo '</p>'
|
||||||
|
|
15
msgfmt
15
msgfmt
|
@ -20,6 +20,9 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
# #
|
# #
|
||||||
|
|
||||||
|
# optional id (for cref errors)
|
||||||
|
id="$1"
|
||||||
|
|
||||||
# HTML replacements (default)
|
# HTML replacements (default)
|
||||||
lquo='\“'
|
lquo='\“'
|
||||||
rquo='\”'
|
rquo='\”'
|
||||||
|
@ -40,9 +43,8 @@ while getopts n opt; do
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
# format the commit message, stopping at the diff (if any)
|
# format the commit message, stopping at the diff (if any)
|
||||||
awk -vurl_root="$url_root" '
|
awk -vid="$id" -vurl_root="$url_root" -vcref_errlog="$cref_errlog" '
|
||||||
# replace commit refs with generated URL (allows linking to prior commits
|
# replace commit refs with generated URL (allows linking to prior commits
|
||||||
# without hard-coding the configurable links that could change or be
|
# without hard-coding the configurable links that could change or be
|
||||||
# relative to where the content is hosted); this will then be processed as a
|
# relative to where the content is hosted); this will then be processed as a
|
||||||
|
@ -52,6 +54,15 @@ awk -vurl_root="$url_root" '
|
||||||
# (which will be reflected once we print the line)
|
# (which will be reflected once we print the line)
|
||||||
c = "./hashcache " g[1]
|
c = "./hashcache " g[1]
|
||||||
c | getline result
|
c | getline result
|
||||||
|
|
||||||
|
# if a cref error logfile path was provided, log unknown refs so that they
|
||||||
|
# can be re-processed (if commits are processed in reverse order and the
|
||||||
|
# hashcache is cleared before the run, then this is likely to occur for
|
||||||
|
# every cref)
|
||||||
|
if ( result == "" && cref_errlog && id ) {
|
||||||
|
printf "^" id >cref_errlog
|
||||||
|
}
|
||||||
|
|
||||||
gsub(/\[cref:.*?\]/, url_root result)
|
gsub(/\[cref:.*?\]/, url_root result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,8 +44,8 @@ EOH
|
||||||
|
|
||||||
prevdate=
|
prevdate=
|
||||||
lastts=
|
lastts=
|
||||||
firstyear=
|
firstyear=0
|
||||||
lastyear=
|
lastyear=0
|
||||||
lasthash=
|
lasthash=
|
||||||
|
|
||||||
# generate index
|
# generate index
|
||||||
|
|
35
repo2html
35
repo2html
|
@ -78,16 +78,35 @@ msgfmt="${msgfmt:-./msgfmt}"
|
||||||
# make configuration available to all scripts
|
# make configuration available to all scripts
|
||||||
export title desc copyright license msgfmt url_root
|
export title desc copyright license msgfmt url_root
|
||||||
|
|
||||||
# clear and prime the cachefile (TODO: we could maintain cache files from
|
# clear the cachefile (TODO: we could maintain cache files from previous runs if
|
||||||
# previous runs if we offer a flag that opts out of reprocessing previously
|
# we offer a flag that opts out of reprocessing previously processed commits)
|
||||||
# processed commits)
|
echo "Clearing hashcache..." >&2
|
||||||
echo "Priming hashcache..." >&2
|
|
||||||
./hashcache clear
|
./hashcache clear
|
||||||
"$repotype"/list | while read hash _ ts id _; do
|
|
||||||
./hashcache "$hash" "$( ./outfgen "$ts" "$id" )"
|
|
||||||
done
|
|
||||||
|
|
||||||
# pass commit list to the HTML and RSS processors
|
# set the cref error log, which will allow us to re-process *only* those commits
|
||||||
|
# that actually need to be reprocessed; this avoids the need to prime the
|
||||||
|
# hashcache, saving cycles
|
||||||
|
cref_errlog_first=.cref-errlog
|
||||||
|
export cref_errlog="$cref_errlog_first"
|
||||||
|
>"$cref_errlog"
|
||||||
|
|
||||||
|
# pass commit list to the HTML and RSS processors (cache list to disk for
|
||||||
|
# reference and further processing)
|
||||||
|
listcache=.list
|
||||||
"$repotype"/list | tee \
|
"$repotype"/list | tee \
|
||||||
>( ./rss "$repotype" "$url_root" "$rss_count" > "$path_out/rss.xml" ) \
|
>( ./rss "$repotype" "$url_root" "$rss_count" > "$path_out/rss.xml" ) \
|
||||||
|
"$listcache" \
|
||||||
| ./processor "$repotype" "$path_out"
|
| ./processor "$repotype" "$path_out"
|
||||||
|
|
||||||
|
# re-process cref errors (but only once; any errors at this point will be
|
||||||
|
# considered to be problem refs)
|
||||||
|
export cref_errlog=.cref-bad
|
||||||
|
>"$cref_errlog"
|
||||||
|
grep -f"$cref_errlog_first" "$listcache" \
|
||||||
|
| ./processor "$repotype" "$path_out" \
|
||||||
|
2> >( sed 's/^/[Reprocessing] /g' >&2 )
|
||||||
|
|
||||||
|
# if any invalid crefs remain, then they're bad
|
||||||
|
[ -s "$cref_errlog" ] && {
|
||||||
|
echo "warning: bad cref(s); see $cref_errlog" >&2
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue