Skip to main content

A very simplistic changelog parser/updater

Project description

parse-changelog

This is a very simplistic changelog updater/parser, with two modes of operation:

  1. Insert a new release into the changelog, using the list of changes from the Unreleased section
  2. Parse the releases in the changelog into a JSON structure.

Changelogs must be in the format documented by Keep a Changelog, see the details below.

Release history: parse-changelog's CHANGELOG

Changelog Updates

The first mode updates the changelog and is invoked by using the --release arg. It walks through the file line-by-line until it finds the unreleased section. Then it inserts a newline and the new release heading, and then writes out the rest of the file unchanged.

The changelog must use the format ## [Unreleased] (case insensitive) for this parser to find it. For example, here is the diff generated by adding a new release "1.0.2" to a changelog:

## [Unreleased]
+
+## [1.0.2] - 2022-10-20
 * Great new stuff
 
 ## [1.0.1] - 2022-10-08

Changelog Parsing

The second mode parses the changelog into JSON and is invoked by not specifying a new --release arg. It finds all of the heading2 entryies (lines starting with ##) and assumes eachh of those is a release. For each release, it parses the release title into version and date, and collects the content of the release as a single string. Each release heading must be of the format ## [release_version] - YYYY-MM-DD, where release_version matches SemVer version string spec, and YYYY-MM-DD is a valid year-month-day. The one exception to this format is the special release heading for unreleased changes, which must match ## [Unreleased]. The content of the release is parsed as a single string and not interpreted in any way. For example, given the following changelog:

# Changelog

My Project Name

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
* Great new stuff

## [1.0.1] - 2022-10-08
### Fixed
* Minor bug that we missed
### Changed
* New name for an artifact

## [1.0.0] - 2022-09-01
Initial release
* Some cool feature
* Other interesting stuff

It will be parsed into this JSON:

{
  "prerelease": {
    "title": "[Unreleased]",
    "content": "* Great new stuff\n",
    "version": "prerelease",
    "date": "unreleased"
  },
  "[1.0.1] - 2022-10-08": {
    "title": "[1.0.1] - 2022-10-08",
    "content": "### Fixed\n* Minor bug that we missed\n### Changed\n* New name for an artifact\n",
    "version": "unknown",
    "date": "unknown"
  },
  "[1.0.0] - 2022-09-01": {
    "title": "[1.0.0] - 2022-09-01",
    "content": "Initial release\n* Some cool feature\n* Other interesting stuff\n",
    "version": "unknown",
    "date": "unknown"
  }
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

parse-changelog-1.0.1.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

parse_changelog-1.0.1-py2.py3-none-any.whl (5.9 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file parse-changelog-1.0.1.tar.gz.

File metadata

  • Download URL: parse-changelog-1.0.1.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.1

File hashes

Hashes for parse-changelog-1.0.1.tar.gz
Algorithm Hash digest
SHA256 03c52b8e0b933f811ec5fdb7f41f56557ea9a2ef28646c37aac30a65cc7ee579
MD5 35079f48368391af762208390d6ed6b4
BLAKE2b-256 46f2d8644c0d2e93b5cb76db394b5cab82e9eaf5574e9d1f86e846ace23f85a7

See more details on using hashes here.

File details

Details for the file parse_changelog-1.0.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for parse_changelog-1.0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 70bb61efb18c88c85a1d45ec42234a7e87a079a329edd722b940aa0ae4a746e5
MD5 ead0f3b22d8a32799d189f7d2939acd4
BLAKE2b-256 4823da877b7dec64830232fa066a22ef50153ad789fa01f19025e7cf622b4bae

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page