1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- #!/bin/sh
- TMP="${TMP:-/tmp}"
- set -euf
- branch="$(git rev-parse --abbrev-ref HEAD)"
- origin=master
- chlog=ChangeLog.txt
- [ "$branch" = $origin ] && { printf %s\\n "Already on '$origin'."; exit 1; }
- [ -f ./$chlog ] || { printf %s\\n "No '$chlog' found."; exit 1; }
- trap 'rm -f -- "$TMP/$chlog.new"; trap - EXIT; exit 0' EXIT INT
- mkdir -p -- "$TMP"
- cat /dev/null > "$TMP/$chlog.new"
- git log --format=%s "$branch" ^$origin --no-merges | while read -r line; do
- [ "${line}" ] || continue
- printf %s\\n "$line" >> "$TMP/$chlog.new"
- done
- date="$(date -u)"
- day="$(date -u +%Y%m%d)"
- tag=1
- while git rev-parse "$day.$tag" >/dev/null 2>&1; do
- tag="$(($tag+1))"
- done
- sed -i '1s/^/+--------------------------+\n/' ./$chlog
- sort < "$TMP/$chlog.new" | sed "1s/^/$date\\n/" |
- cat - ./$chlog > "$TMP/$chlog.tmp"
- mv -- "$TMP/$chlog.tmp" ./$chlog
- git add ./$chlog
- git commit -m "Public www update: $date."
- git tag "$day.$tag"
|