-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
411 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[[source]] | ||
name = "pypi" | ||
url = "https://pypi.org/simple" | ||
verify_ssl = true | ||
|
||
[dev-packages] | ||
rope = "*" | ||
# yapf is used for formatting the code | ||
yapf = "*" | ||
autopep8 = "*" | ||
# flake8 is used for linting | ||
flake8 = "*" | ||
# isort is used for sort imports | ||
# Usage: isort *.py | ||
isort = "*" | ||
pipenv = "*" | ||
twine = "*" | ||
|
||
[packages] | ||
gitpython = "*" | ||
|
||
[requires] | ||
python_version = "3.6" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,22 @@ | ||
# Bumping | ||
|
||
Python tool to calculate SemVer based on conventional git commit messages. | ||
|
||
## Prerequisite | ||
|
||
- Python >= 3 | ||
|
||
## Installation | ||
|
||
```bash | ||
pip install bumping | ||
``` | ||
|
||
## Usage | ||
|
||
Execute `bumping` and the calculated version would be printed. | ||
|
||
```bash | ||
$ bumping | ||
0.1.1 | ||
``` |
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 @@ | ||
__version__ = '0.1.0' |
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,38 @@ | ||
import re | ||
|
||
from git import Repo, Commit | ||
|
||
_prog = re.compile(r'^([^\(\)]+?)(\([^\(\)]+\))?: [\s\S]+$') | ||
|
||
_increment_map = { | ||
'BREAKING CHANGE': (1, 0, 0), | ||
'feat': (0, 1, 0), | ||
'fix': (0, 0, 1), | ||
} | ||
_increment_map.setdefault(None) | ||
|
||
|
||
def get_commit_type(message: str) -> str: | ||
m = _prog.match(message) | ||
if m: | ||
return m.group(1) | ||
|
||
|
||
def get_increment(type: str) -> tuple: | ||
return _increment_map[type] | ||
|
||
|
||
def get_commit_increment(message: str) -> tuple: | ||
type = get_commit_type(message) | ||
return get_increment(type) | ||
|
||
|
||
def main(): | ||
repo = Repo('.') | ||
|
||
for commit in repo.iter_commits('HEAD'): | ||
print('%-10s%s' % (get_commit_increment(commit.message), commit.message)) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
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,37 @@ | ||
import unittest | ||
|
||
from bumping import bumping | ||
|
||
|
||
class TestBumping(unittest.TestCase): | ||
def test_get_commit_type(self): | ||
asserts = ( | ||
('feat: xxx', 'feat'), | ||
('feat(xxx): xxx', 'feat'), | ||
('feat(xxx): ', None), | ||
('feat xxx', None), | ||
('fix: xxx', 'fix'), | ||
('BREAKING CHANGE: xxx', 'BREAKING CHANGE'), | ||
('BREAKING CHANGE(xxx): xxx', 'BREAKING CHANGE'), | ||
('chore: xxx', 'chore'), | ||
('docs: xxx', 'docs'), | ||
) | ||
|
||
for message, expected in asserts: | ||
self.assertEqual(expected, bumping.get_commit_type(message)) | ||
|
||
def test_get_commit_increment(self): | ||
asserts = ( | ||
('feat: xxx', (0, 1, 0)), | ||
('feat(xxx): xxx', (0, 1, 0)), | ||
('fix: xxx', (0, 0, 1)), | ||
('BREAKING CHANGE: XXX', (1, 0, 0)), | ||
('feat xxx', None), | ||
) | ||
|
||
for message, expected in asserts: | ||
self.assertEqual(expected, bumping.get_commit_increment(message)) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
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,3 @@ | ||
import runpy | ||
|
||
runpy.run_module('bumping.bumping', run_name='__main__') |
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,21 @@ | ||
[metadata] | ||
name = bumping | ||
author = wqy | ||
author_email = qiyingwangwqy@gmail.com | ||
description = Python tool to calculate SemVer based on conventional git commit messages. | ||
long_description = file: README.md, CHANGELOG.md | ||
long_description_content_type = text/markdown | ||
url = https://github.com/WqyJh/bumping | ||
keywords = git, conventionalcommits, SemVer | ||
license_files = LICENSE | ||
classifiers = | ||
Programming Language :: Python :: 3 :: Only | ||
|
||
|
||
[options] | ||
include_package_data = True | ||
packages = find: | ||
|
||
|
||
[options.package_data] | ||
* = *.txt, *.rst, *.md |
Oops, something went wrong.