Skip to content

Instantly share code, notes, and snippets.

@DanielCardonaRojas
Last active August 5, 2020 23:31
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 DanielCardonaRojas/cf861172f4c9084575c6729921720e08 to your computer and use it in GitHub Desktop.
Save DanielCardonaRojas/cf861172f4c9084575c6729921720e08 to your computer and use it in GitHub Desktop.
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
Copy link
Author

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
Copy link
Author

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