#!/bin/bash # This script comes with ABSOLUTELY NO WARRANTY, use at own risk # Copyright (C) 2021 Osiris Alejandro Gomez # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . [[ -z "$1" ]] && exit 1 [[ -e "$1" ]] || exit 1 FILE="$1" TMP1="$(mktemp)" TMP2="$(mktemp)" GIT_ORIGIN="$(git remote get-url origin | tr : / | sed 's/git@//g')" GIT_URL="https://$GIT_ORIGIN/-/commit" printf "\n** ChangeLog\n\n" > "$TMP1" git log --no-merges --format=" - [[$GIT_URL/%H][=%ci=]] %s" "$FILE" \ | grep -v 'ChangeLog:' \ | sed 's/ -0300//g' \ | sed 's/ +0000//g' \ | cut -d: -f1,2,4- >> "$TMP1" N="$(grep -En '^\*\* ChangeLog$' "$FILE" | cut -d: -f1 | head -1)" if [[ "$N" -gt 0 ]] then LINE=$((N-1)) head -n "$LINE" "$FILE" > "$TMP2" cat "$TMP1" >> "$TMP2" & mv -vf "$TMP2" "$FILE" else cat "$TMP1" >> "$FILE" fi