Skip to content

Instantly share code, notes, and snippets.

@pwillis-els
Created January 25, 2022 16:24
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 pwillis-els/5cc19572ea6f8c8e970917917105c495 to your computer and use it in GitHub Desktop.
Save pwillis-els/5cc19572ea6f8c8e970917917105c495 to your computer and use it in GitHub Desktop.
Make a Git Changelog by hand

Making a Changelog by hand with Git

If you need to create a ChangeLog for a repository, there's a lot of software out there than can help you generate one. But most of it works by having your Git commits include certain information. What if you want to make a ChangeLog for software whose commit messages are not uniform?

Basically, just use git log to compare commits to your existing ChangeLog, and format the Changelog entry for a new release (using the Keep A Changelog format).

First add a shortcut to format Git logs to only show you the changes:

git config --global alias.clog '!git log --date=relative --pretty=" %x23 %Cgreen%<(60,trunc)%s%Creset (%Cblue%ad%Creset)%n%w(75,6,6)%b%n"'

Then save the Git logs since your last release to a file:

git clog v0.11..HEAD > new-changes.tmp

Then view your old Changelog and your new changes side-by-side, and update your Changelog by hand using the Keep a Changelog format. Just scroll through your commits and add a line to your Changelog release with whether that commit added, changed, or fixed something.

I use Vim in split-view mode in a terminal that's about 140 characters wide, but you can use whatever tool lets you view files side-by-side.

vim -O CHANGELOG.md new-changes.tmp
# Changelog                                                                    | # Try to fix postgres test                                     (10 hours ago)
                                                                               |
## [v0.12] - 2022-01-25                                                        |
                                                                               | # Release v0.12                                                (11 hours ago)
### Added                                                                      |
 - Option '-n' (NO_CLEANUP_TMP=1) prevents removing the dynamic TF_DATA_DIR    |
 - Wrappers for most Terraform commands (workspace, console, output, taint, unt| # Fix 'import' not running previous 'init', add force-unlock.. (3 days ago)
aint, force-unlock)                                                            |
 - '-backup=' option added to 'terraformsh state rm ...' commands              |
                                                                               | # Don't run 'terraform init' twice in the same run             (3 days ago)
### Changed                                                                    |
 - Removal of temporary TF_DATA_DIR is avoided only if NO_CLEANUP_TMP_ON_ERROR=|
1 . Before it would have left the directory intact on error, leading to it bein| # Fix 'output' wrapper, add 'taint' and 'untaint' wrappers     (3 days ago)
g re-used the next time.                                                       |
 - Check for files with '-e', do not check if they're readable with '-r'       |
 - Prevent re-running 'terraform init' multiple times in same session          | # Add todo item                                                (3 days ago)
                                                                               |
### Fixed                                                                      |
 - Location of default plan file                                               | # Add a '-backup=' option to 'terraformsh state rm ...' auto.. (7 days ago)
 - 'terraform validate' for newer versions of Terraform                        |      This change creates a backup state file whenever you run 'terraformsh
 - Passing arbitrary options to commands                                       |      state rm ...'. The backup file appears in the local directory and has
 - Detecting sub-commands of parent commands                                   |      a randomly-generated name. This way you don't need to remember to
 - Detecting previously-set TF_DATA_DIR                                        |      create and maintain backup files when you remove a state item.
 - Run 'init' before 'import                                                   |
                                                                               |
---                                                                            | # Fix weird error                                              (2 weeks ago)
                                                                               |      When running terraformsh from a Jenkins job (using a Docker agent),
## [v0.11] - 2021-11-02                                                        |      the
                                                                               |      '-r' test always seems to fail, even though the file cat be 'cat'ed
### Added                                                                      |      from the same session using '-r'.
 - Unit tests (only 3 so far)                                                  |
 - GitHub Actions integration                                                  |      I don't know yet what's going on, but changing from '-r' to '-e' at

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