Documentation ¶
Index ¶
- Constants
- Variables
- func ParseSectionFromType(logSpec ConventionalChangeLogSpec, commitType string) string
- func RaymondParseAst(input string) (*ast.Program, error)
- func RaymondRender(template string, payload interface{}) (s string, err error)
- type BreakingChanges
- type Commit
- func ConvertGitCommits2ConventionCommits(commits []git.Commit, spec ConventionalChangeLogSpec, ...) ([]Commit, error)
- func NewCommit(c git.Commit) (Commit, error)
- func NewCommitWithLogSpec(c git.Commit, spec ConventionalChangeLogSpec, ...) (Commit, error)
- func NewCommitWithOptions(opts ...OptionFn) (result Commit, err error)
- type CommitRenderTemplate
- type CompareRenderTemplate
- type ConventionalChangeLogSpec
- func DefaultConventionalChangeLogSpec() ConventionalChangeLogSpec
- func LoadConventionalChangeLogSpecByData(logSpec []byte) (*ConventionalChangeLogSpec, error)
- func LoadConventionalChangeLogSpecByPath(specFilePath string) (*ConventionalChangeLogSpec, error)
- func SimplifyConventionalChangeLogSpec() *ConventionalChangeLogSpec
- type GitRepositoryHttpInfo
- type GitUrlRenderTemplate
- type IssueInfo
- type IssueRenderTemplate
- type OptionFn
- type ReleaseCommitMessageRenderTemplate
- type Types
Constants ¶
const ( DefaultSemverVersion = "1.0.0" DefaultHeader = "Changelog" DefaultCommitUrlFormat = "{{scheme}}://{{host}}/{{owner}}/{{repository}}/commit/{{hash}}" DefaultCompareUrlFormat = "{{scheme}}://{{host}}/{{owner}}/{{repository}}/compare/{{previousTag}}...{{currentTag}}" DefaultIssueUrlFormat = "{{scheme}}://{{host}}/{{owner}}/{{repository}}/issues/{{id}}" DefaultUserUrlFormat = "{{scheme}://{{host}}/{{user}}" DefaultReleaseCommitMessageFormat = "chore(release): {{currentTag}}" )
const ( FeatType = "feat" FixType = "fix" DocsType = "docs" StyleType = "style" RefactorType = "refactor" PerfType = "perf" TestType = "test" BuildType = "build" CIType = "ci" ChoreType = "chore" RevertType = "revert" MiscType = "misc" )
const (
MarkdownBreakingChangesToken = "BREAKING CHANGE: "
)
Variables ¶
var (
ErrEmptyCommit = errors.New("empty commit")
)
Functions ¶
func ParseSectionFromType ¶
func ParseSectionFromType(logSpec ConventionalChangeLogSpec, commitType string) string
ParseSectionFromType
parse section from type if not found, return type itself
func RaymondParseAst ¶
RaymondParseAst parse by input
func RaymondRender ¶
RaymondRender parses and executes a template, returning the results in string format. Trailing or leading spaces or new-lines are not getting truncated. It is able to read templates from remote paths, local files or directly from the string.
Types ¶
type BreakingChanges ¶
type BreakingChanges struct {
Describe string
}
type Commit ¶
type Commit struct { // Commit as is RawHeader string Type string Scope string BreakingChanges BreakingChanges IssueInfo IssueInfo }
Commit conventional commit
func ConvertGitCommits2ConventionCommits ¶
func ConvertGitCommits2ConventionCommits(commits []git.Commit, spec ConventionalChangeLogSpec, gitHttpInfo GitRepositoryHttpInfo) ([]Commit, error)
func NewCommitWithLogSpec ¶
func NewCommitWithLogSpec(c git.Commit, spec ConventionalChangeLogSpec, gitHttpInfo GitRepositoryHttpInfo) (Commit, error)
NewCommitWithLogSpec
c git.Commit
spec ConventionalChangeLogSpec
gitHttpInfo git info by GitRepositoryHttpInfo
this method not add AddAuthorDate
return conventional commit from git commit
func NewCommitWithOptions ¶
NewCommitWithOptions return conventional commit with custom option
func (*Commit) AppendMarkdownCommitLink ¶
func (c *Commit) AppendMarkdownCommitLink(commitUrlFormat string, shortHash, hash string, gitHttpInfo GitRepositoryHttpInfo) error
AppendMarkdownCommitLink will append [shortHash](RaymondRender(commitUrlFormat)) by {{scheme}}://{{Host}}/{{Owner}}/{{Repository}}/commit/{{Hash}}
type CommitRenderTemplate ¶
type CommitRenderTemplate struct { GitUrlRenderTemplate Hash string `handlebars:"hash"` }
CommitRenderTemplate default template is DefaultCommitUrlFormat
type CompareRenderTemplate ¶
type CompareRenderTemplate struct { GitUrlRenderTemplate PreviousTag string `handlebars:"previousTag"` CurrentTag string `handlebars:"currentTag"` }
CompareRenderTemplate default template is DefaultCompareUrlFormat
type ConventionalChangeLogSpec ¶
type ConventionalChangeLogSpec struct { // Types // Types []Types `json:"types,omitempty"` // TagPrefix // default is v TagPrefix string `json:"tag-prefix,omitempty"` // HashLength // default is 8 HashLength uint `json:"hash-length,omitempty"` // IssuePrefixes // default is ["#"] IssuePrefixes []string `json:"issuePrefixes,omitempty"` // Header // A string to be used as the main header of the CHANGELOG // default DefaultHeader Header string `json:"header,omitempty"` // CommitUrlFormat // A URL representing a specific commit at a Hash // default DefaultCommitUrlFormat CommitUrlFormat string `json:"commitUrlFormat,omitempty"` // CompareUrlFormat // A URL representing the comparison between two git shas // default DefaultCompareUrlFormat CompareUrlFormat string `json:"compareUrlFormat,omitempty"` // IssueUrlFormat // A URL representing the issue format (allowing a different URL format to be swapped in for Gitlab, Bitbucket, etc) // default DefaultIssueUrlFormat IssueUrlFormat string `json:"issueUrlFormat,omitempty"` // UserUrlFormat // A URL representing a user's profile URL on GitHub, Gitlab, etc. This URL is used for substituting @bcoe with https://github.com/bcoe in commit messages. // default DefaultUserUrlFormat UserUrlFormat string `json:"userUrlFormat,omitempty"` // ReleaseCommitMessageFormat // A string to be used to format the auto-generated release commit message // default DefaultReleaseCommitMessageFormat ReleaseCommitMessageFormat string `json:"releaseCommitMessageFormat,omitempty"` // CoverHttpHost // this will cover all http host CoverHttpHost string `json:"cover-http-host,omitempty"` // MonoRepoPkgPathList // monorepo package path list MonoRepoPkgPathList []string `json:"monorepo-pkg-path,omitempty"` }
ConventionalChangeLogSpec struct scheme See: https://github.com/conventional-changelog/conventional-changelog-config-spec/blob/master/versions/2.2.0/schema.json
func DefaultConventionalChangeLogSpec ¶
func DefaultConventionalChangeLogSpec() ConventionalChangeLogSpec
DefaultConventionalChangeLogSpec
func LoadConventionalChangeLogSpecByData ¶
func LoadConventionalChangeLogSpecByData(logSpec []byte) (*ConventionalChangeLogSpec, error)
LoadConventionalChangeLogSpecByData
this function will load ConventionalChangeLogSpec from json data if type sort is 0, will set default sort by convention.defaultType
func LoadConventionalChangeLogSpecByPath ¶ added in v1.2.0
func LoadConventionalChangeLogSpecByPath(specFilePath string) (*ConventionalChangeLogSpec, error)
LoadConventionalChangeLogSpecByPath
load ConventionalChangeLogSpec by path
if path not exists, will return default spec
func SimplifyConventionalChangeLogSpec ¶
func SimplifyConventionalChangeLogSpec() *ConventionalChangeLogSpec
SimplifyConventionalChangeLogSpec return simplify ConventionalChangeLogSpec
type GitRepositoryHttpInfo ¶
type GitRepositoryHttpInfo struct { // Scheme is the protocol scheme of the remote host. https or http. // do not use git+ssh, it will be some error Scheme string // Host is the hostname:port of the remote host. Host string // Owner is the owner of the repository. Owner string // Repository is the name of the repository. Repository string }
type GitUrlRenderTemplate ¶
type GitUrlRenderTemplate struct { Scheme string `handlebars:"scheme"` Host string `handlebars:"host"` Owner string `handlebars:"owner"` Repository string `handlebars:"repository"` }
GitUrlRenderTemplate default template is DefaultUserUrlFormat
type IssueRenderTemplate ¶
type IssueRenderTemplate struct { GitUrlRenderTemplate Id string `handlebars:"id"` }
IssueRenderTemplate default template is DefaultIssueUrlFormat
type OptionFn ¶
func AddAuthorDate ¶
func GetBreakChangesAndIssue ¶
func GetBreakChangesAndIssue(gitCommit git.Commit, spec ConventionalChangeLogSpec) OptionFn
func GetRawHeader ¶
func GetTypeAndScope ¶
type ReleaseCommitMessageRenderTemplate ¶
type ReleaseCommitMessageRenderTemplate struct {
CurrentTag string `handlebars:"currentTag"`
}
ReleaseCommitMessageRenderTemplate default template is DefaultReleaseCommitMessageFormat