go-semantic-release / semantic-release

📦🚀 semantic-release written in Go
https://go-semantic-release.xyz
MIT License
405 stars 43 forks source link

Using BREAKING CHANGE #15

Closed Rossiar closed 5 years ago

Rossiar commented 5 years ago

Hi - just wanted some guidance on using BREAKING CHANGE as specified in the original project docs: https://github.com/semantic-release/semantic-release/blob/master/README.md

There doesn't seem to be support for this as currently this line will fail to match a commit message like BREAKING CHANGE: merry christmas guys:

func parseCommit(commit *github.RepositoryCommit) *Commit {
    c := new(Commit)
    c.SHA = commit.GetSHA()
    c.Raw = strings.Split(commit.Commit.GetMessage(), "\n")
    found := commitPattern.FindAllStringSubmatch(c.Raw[0], -1)
    if len(found) < 1 {
        return c
    }
    c.Type = strings.ToLower(found[0][1])
    c.Scope = found[0][2]
    c.Message = found[0][3]
    c.Change = Change{
        Major: breakingPattern.MatchString(commit.Commit.GetMessage()),
        Minor: c.Type == "feat",
        Patch: c.Type == "fix",
    }
    return c
}

In the code above commitPattern is relying on word characters (\w) to match before the : and so it will not match against BREAKING CHANGE as ` is not a word character, as such thefoundarray will be empty and theparseCommitfunction will exit early and not assign aChange` to the commit.

I was mainly wondering if this was intentional or not and if you would accept a PR from our fork to resolve this if it is indeed a bug?

christophwitzko commented 5 years ago

Hi @Rossiar,

if you want to introduce a new breaking change with a commit, you still need to stick to the Angular Commit Message Conventions. That means that the BREAKING CHANGE keyword is part of the commit body or footer.

This is how a breaking change commit message should look like:

feat: this new feature changes the API behavior

BREAKING CHANGE: merry christmas
Rossiar commented 5 years ago

Hi @christophwitzko,

Thanks for clearing up my misunderstanding!