Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
git release notes #git #awk #release #notes
#! /usr/bin/awk -f
BEGIN {
FS="\][ ]*[-]*[ ]*"
}
/^\[.*\]/ {
sub(/\[/, "", $1)
if (NR == 1) {
previous_commit_tag = $1
commit_message = "\t- " $2
print previous_commit_tag "\n" commit_message
next
}
commit_message = "\t- " $2
commit_tag = $1
if(previous_commit_tag != commit_tag) {
print"\n" commit_tag "\n" commit_message
} else {
print commit_message
}
previous_commit_tag = commit_tag
}
END {}
#!/bin/bash
set -e
PAST_TAG=$(git describe --tags --abbrev=0)
REF=${1:-$PAST_TAG}
git log $REF..HEAD --pretty=format:"%s" | ./format_git_log
@DanielCardonaRojas

This comment has been minimized.

Copy link
Owner Author

@DanielCardonaRojas DanielCardonaRojas commented Jul 11, 2020

Usage

Put both scripts in same location.

Get formatted output from latest git tag to HEAD:

./git_release_notes.sh

Get formatter output from a give commit to HEAD:

./git_release_notes.sh COMMIT_HASH

Output

Process git log where commits have been written in the format. of:

[JIRA_TICKET_ID] COMMIT_MSG or [JIRA_TICKET_ID] - COMMIT_MSG

If multiple lines have the same ticket id these will be summarized in a section like. this

JIRA_TICKET_ID
    - COMMIT_MSG_1
   - COMMIT_MSG_2

JIRA_TICKET_ID
    -  COMMIT_MSG_1
    - COMMIT_MSG_2
@DanielCardonaRojas

This comment has been minimized.

Copy link
Owner Author

@DanielCardonaRojas DanielCardonaRojas commented Jul 12, 2020

TODO, first parse a git commit. template.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment