-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add commitizen changelog generation and automatic release task #138
Open
tfiedlerdejanze
wants to merge
3
commits into
master
Choose a base branch
from
issue-135-fully-automated-release-task
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
defmodule Expublish.Commitizen do | ||
@moduledoc """ | ||
Implements commitizen specification. | ||
|
||
https://www.conventionalcommits.org/en/v1.0.0/#specification | ||
""" | ||
|
||
defstruct all: [], patch: [], feature: [], breaking: [] | ||
|
||
def run(commits) do | ||
collect(commits) | ||
end | ||
|
||
defp collect(commits, acc \\ %__MODULE__{}) | ||
|
||
defp collect([], acc), do: acc | ||
|
||
defp collect(["fix" <> _ = commit | rest], acc) do | ||
collect(rest, %__MODULE__{acc | all: [commit | acc.all], patch: [commit | acc.patch]}) | ||
end | ||
|
||
defp collect(["feat" <> _ = commit | rest], acc) do | ||
collect(rest, %__MODULE__{acc | all: [commit | acc.all], feature: [commit | acc.feature]}) | ||
end | ||
|
||
defp collect(["BREAKING CHANGE" <> _ = commit | rest], acc) do | ||
collect(rest, %__MODULE__{acc | all: [commit | acc.all], breaking: [commit | acc.breaking]}) | ||
end | ||
|
||
defp collect([_ | rest], acc) do | ||
collect(rest, acc) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
defmodule CommitizenTest do | ||
use ExUnit.Case | ||
|
||
test "groups commits" do | ||
commits = [ | ||
"fix: i fix something", | ||
"feat: i add a feature", | ||
"BREAKING CHANGE: i break something", | ||
"not noteworthy" | ||
] | ||
|
||
assert %{all: [_, _, _], patch: [_], feature: [_], breaking: [_]} = Expublish.Commitizen.run(commits) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand correctly the specification,
BREAKING CHANGE:
is not a valid type for a commit. That is, a commit subject cannot start withBREAKING CHANGE: <description>
.BREAKING CHANGE
(orBREAKING-CHANGE
) is a valid token to be found in the footer.If we want to indicate a breaking change by looking only at the first line of the commit, we should look for a
!
after the commit type (or scope), like infix!: some fix that is also a breaking change
orfix(parser)!: some fix to the parser that is a breaking change
.Unfortunately, this implies
--oneline
cannot be used https://github.com/tfiedlerdejanze/expublish/pull/138/files#diff-2c4e7ba552cf4684b4bc0dd08450ff59592e3e8b06e4675ef3aa3f580862f0bbR74 as we need the full commit message to look for a possibleBREAKING CHANGE
token.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A naïve attempt to be closer to the spec wrt breaking changes(while still using
--oneline
for fetching commits): marc0s@ecae0d0