parser

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 11, 2021 License: MIT Imports: 3 Imported by: 3

README

Parser

A simple go parser for Conventional Commits

Usage
var msg = `feat(scope): description

this is first line in body

this is second line in body

Ref: #123
Date: 01-01-2021
By: John Doe`

commit, err := Parse(msg)
if err != nil {
    fmt.Printf("Error: %s", err.Error())
}
fmt.Printf("%#v", commit)

/*
commitMsg = &parser.Commit{
  Header: parser.Header{
    Type: "feat",
    Scope: "scope",
    Description: "description",
    FullHeader: "feat(scope): description",
  },
  Body: "this is first line in body\n\nthis is second line in body",
  Footer: parser.Footer{
    Notes: []parser.FooterNote{
      parser.FooterNote{
        Token: "Ref",
        Value: "#123",
      },
      parser.FooterNote{
        Token: "Date",
        Value: "01-01-2021",
      },
      parser.FooterNote{
        Token: "By",
        Value: "John Doe",
      },
    },
    FullFooter: "Ref: #123\nDate: 01-01-2021\nBy: John Doe",
  },
  BreakingChange: false,
  FullCommit: "feat(scope): description\n\nthis is first line in body\n\nthis is second line in body\n\nRef: #123\nDate: 01-01-2021\nBy: John Doe",
}
*/
Fork

This parser is a fork of cov-commit-parser by Matthew Bamber

License

MIT License

Documentation

Overview

Package parser provides a simple parser for conventional commits

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Commit

type Commit struct {
	Header Header
	Body   string
	Footer Footer

	BreakingChange bool

	FullCommit string
}

Commit represents a commit that adheres to the conventional commits specification

func Parse

func Parse(message string) (*Commit, error)

Parse attempts to parse a commit message to a conventional commit

type Footer struct {
	Notes      []FooterNote
	FullFooter string
}

Footer represents Footer in commit message

type FooterNote

type FooterNote struct {
	Token string
	Value string
}

FooterNote represents one footer note in Footer

type Header struct {
	Type        string
	Scope       string
	Description string
	FullHeader  string
}

Header represents Header in commit message

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL