-
-
Notifications
You must be signed in to change notification settings - Fork 301
Fix/16 move breaking change to body #17
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0f0813c
refactor(commit): moved most of the commit logic to the commit command
woile f1f5841
refactor(example): command logic removed from commitizen base
woile 1e9a827
refactor(info): command logic removed from commitizen base
woile 8425c7f
refactor(schema): command logic removed from commitizen base
woile c8ae205
fix: conventional commit 'breaking change' in body instead of title
woile b2d3f9c
fix(bump): commit message now fits better with semver
woile 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
@@ -1,96 +1,26 @@ | ||
import sys | ||
import logging | ||
|
||
from commitizen import out, git | ||
from abc import ABCMeta, abstractmethod | ||
from questionary import prompt | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class BaseCommitizen(metaclass=ABCMeta): | ||
def __init__(self, config: dict): | ||
self.config = config | ||
|
||
@abstractmethod | ||
def questions(self): | ||
"""Questions regarding the commit message. | ||
|
||
Must have 'whaaaaat' format. | ||
More info: https://github.com/finklabs/whaaaaat/ | ||
|
||
:rtype: list | ||
""" | ||
def questions(self) -> list: | ||
"""Questions regarding the commit message.""" | ||
|
||
@abstractmethod | ||
def message(self, answers): | ||
"""Format your git message. | ||
|
||
:param answers: Use answers | ||
:type answers: dict | ||
def message(self, answers: dict) -> str: | ||
"""Format your git message.""" | ||
|
||
:rtype: string | ||
""" | ||
|
||
def commit(self, message: str): | ||
c = git.commit(message) | ||
# f = NamedTemporaryFile("wb", delete=False) | ||
# f.write(message.encode("utf-8")) | ||
# f.close() | ||
|
||
# c = cmd.run(f"git commit -F {f.name}") | ||
# os.unlink(f.name) | ||
return c | ||
|
||
def example(self): | ||
"""Example of the commit message. | ||
|
||
:rtype: string | ||
""" | ||
def example(self) -> str: | ||
"""Example of the commit message.""" | ||
raise NotImplementedError("Not Implemented yet") | ||
|
||
def schema(self): | ||
"""Schema definition of the commit message. | ||
|
||
:rtype: string | ||
""" | ||
def schema(self) -> str: | ||
"""Schema definition of the commit message.""" | ||
raise NotImplementedError("Not Implemented yet") | ||
|
||
def info(self): | ||
"""Information about the standardized commit message. | ||
|
||
:rtype: string | ||
""" | ||
def info(self) -> str: | ||
"""Information about the standardized commit message.""" | ||
raise NotImplementedError("Not Implemented yet") | ||
|
||
def show_example(self, *args, **kwargs): | ||
out.write(self.example()) | ||
|
||
def show_schema(self, *args, **kwargs): | ||
out.write(self.schema()) | ||
|
||
def show_info(self, *args, **kwargs): | ||
out.write(self.info()) | ||
|
||
def run(self, *args, **kwargs): | ||
questions = self.questions() | ||
answers = prompt(questions) | ||
logger.debug("Answers:\n %s", answers) | ||
m = self.message(answers) | ||
logger.debug("Commit message generated:\n %s", m) | ||
|
||
c = self.commit(m) | ||
|
||
if c.err: | ||
logger.warning(c.err) | ||
sys.exit(1) | ||
|
||
if "nothing added" in c.out or "no changes added to commit" in c.out: | ||
out.error(c.out) | ||
elif c.err: | ||
out.error(c.err) | ||
else: | ||
out.write(c.out) | ||
out.success("Commit successful!") | ||
|
||
sys.exit(0) |
This file contains hidden or 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
39 changes: 25 additions & 14 deletions
commitizen/cz/conventional_commits/conventional_commits_info.txt
This file contains hidden or 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 |
---|---|---|
@@ -1,20 +1,31 @@ | ||
Commit Message Format | ||
The commit contains the following structural elements, to communicate | ||
intent to the consumers of your library: | ||
|
||
Each commit message consists of a header, a body and a footer. The header has a special format that | ||
includes a type, a scope and a subject: | ||
fix: a commit of the type fix patches a bug in your codebase | ||
(this correlates with PATCH in semantic versioning). | ||
|
||
<type>(<scope>): <subject> | ||
<BLANK LINE> | ||
<body> | ||
<BLANK LINE> | ||
<footer> | ||
feat: a commit of the type feat introduces a new feature to the codebase | ||
(this correlates with MINOR in semantic versioning). | ||
|
||
The header is mandatory and the scope of the header is optional. | ||
BREAKING CHANGE: a commit that has the text BREAKING CHANGE: at the beginning of | ||
its optional body or footer section introduces a breaking API change | ||
(correlating with MAJOR in semantic versioning). | ||
A BREAKING CHANGE can be part of commits of any type. | ||
|
||
Any line of the commit message cannot be longer 100 characters! This allows the message to be easier | ||
to read on GitHub as well as in various git tools. | ||
Others: commit types other than fix: and feat: are allowed, | ||
like chore:, docs:, style:, refactor:, perf:, test:, and others. | ||
|
||
Footer should contain a closing reference to an issue if any. | ||
We also recommend improvement for commits that improve a current | ||
implementation without adding a new feature or fixing a bug. | ||
|
||
This leads to more readable messages that are easy to follow when looking through the project history. | ||
But also, the git commit messages can be used to generate the changelog. | ||
Notice these types are not mandated by the conventional commits specification, | ||
and have no implicit effect in semantic versioning (unless they include a BREAKING CHANGE). | ||
|
||
A scope may be provided to a commit’s type, to provide additional contextual | ||
information and is contained within parenthesis, e.g., feat(parser): add ability to parse arrays. | ||
|
||
<type>[optional scope]: <description> | ||
|
||
[optional body] | ||
|
||
[optional footer] |
This file contains hidden or 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.