Partas.Tools.ConventionalCommits 0.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Partas.Tools.ConventionalCommits --version 0.1.0
                    
NuGet\Install-Package Partas.Tools.ConventionalCommits -Version 0.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Partas.Tools.ConventionalCommits" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Partas.Tools.ConventionalCommits" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Partas.Tools.ConventionalCommits" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Partas.Tools.ConventionalCommits --version 0.1.0
                    
#r "nuget: Partas.Tools.ConventionalCommits, 0.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Partas.Tools.ConventionalCommits@0.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Partas.Tools.ConventionalCommits&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Partas.Tools.ConventionalCommits&version=0.1.0
                    
Install as a Cake Tool

Partas.Tools.ConventionalCommits

---
title: Partas.Tools.ConventionalCommits
---
gitGraph
    commit id: "feat: XParsec parser"
    commit id: "chore: README.md"
    branch develop
    commit id: "add: F# Record types"
    commit id: "add: DUs"
    commit id: "feat: Parser entry point"
    commit id: "chore: tests"
    checkout main
    merge develop id: "feat!: 0.1.0" tag: "0.1.0"

A parser for Conventional Commit strings using XParsec.

The parser follows the Conventional Commit specs.

Since this uses XParsec, we expect Fable compatibility, this will be tested when Fable 5.0 is released, as I don't plan on supporting previous releases (an unfortunate side effect of all my current work being on Fable v5 alphas).

Types

ConventionalCommit

A conventional commit is a record of the following shape:

type ConventionalCommit = {
        Type: string
        Scope: string voption
        Subject: string // AKA Description
        Message: string voption
        Footers: Footer list
    }

ParsedCommit

Parsed Commits are packaged in a Discriminated Union to identify failed parses, breaking changes, and conventional commits.

type ParsedCommit =
    | Unconventional of string
    | Conventional of ConventionalCommit
    | Breaking of ConventionalCommit

Footers are also packaged in a discriminated union:

type Footer =
    | Footer of key: string * value: string
    | BreakingChange of value: string

You can use the helper property Destructure to ignore matching the union and unpacking a string * string tuple (in the case of a breaking change, a literal is used for the key - whether BREAKING-CHANGE or BREAKING CHANGE is used won't change the literal).

Parsing

There are two flavors of the parser.

module ConventionalCommit =
    let parse (input: string): ParsedCommit
    let parseConventionalOrError (input: string): Result<ParsedCommit, string>

parse

This is typical usage, and will return the Unconventional case with the string input when the commit message does not meet the spec.

parseConventionalOrError

This is used for strict adherance, or to see why a commit message wasn't parsed.

The success case is guaranteed to be either the Conventional or Breaking cases of ParsedCommit. If the parser fails to make a conventional commit, then it will return the failure case with XParsec formatted error strings:

Example of error formatting:

"typscope): asdomfe"
|> parseConventionalOrError
|> Result.mapError (printfn "%A)
"typscope): asdomf
        ^ At index 8 (Ln 1, Col 9)
Both parsers failed.
├───Expected '('
└───Both parsers failed.
    ├───Expected ':'
    └───Expected '!'"

Spec

The parser meets the spec, but automatically lower cases case-insensitive proponents such as the Type, Scope and Footer keys.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Partas.Tools.ConventionalCommits:

Package Downloads
Partas.GitNet

Git that .Net F#

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.3.0 159 8/15/2025
0.2.0 100 8/15/2025
0.1.0 102 8/3/2025

Initial release