Skip to content

Instantly share code, notes, and snippets.

@bewest
Last active June 18, 2016 22:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bewest/85ff1a8cb76ece1a8d0369361d854328 to your computer and use it in GitHub Desktop.
Save bewest/85ff1a8cb76ece1a8d0369361d854328 to your computer and use it in GitHub Desktop.
mk-time-series from openaps git logs
#!/bin/bash
# oref0-predict/oref0.json
INPUT=$1
TEST_EXEC="if (Array.isArray(this)) { process.exit(1); }"
git log \
--format="format:%h %aI %s" \
-n 100 --follow -- $INPUT \
| while read hash iso subject ; do
spec=$hash:$INPUT
git show $spec \
| ( json -A -e "$TEST_EXEC" || ( echo "{}" \
| json -0 -e "this.slice = $(git show $spec )"
) ) 2>/dev/null \
| json -0 -e "this.dateString = '$iso'" \
| json -0 -e "this.subject = '$subject'" \
| json -0 -e "this.hash = '$hash'"
done | json -ga -0 | json -g
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment