-
Notifications
You must be signed in to change notification settings - Fork 248
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
7 changed files
with
73 additions
and
34 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
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,15 @@ | ||
from git import Repo | ||
from invoke import run | ||
from semantic_release.settings import load_config | ||
|
||
|
||
def get_commit_log(): | ||
repo = Repo('.git') | ||
for commit in repo.iter_commits(): | ||
yield commit.message | ||
|
||
|
||
def commit_new_version(version): | ||
add = run('git add {}'.format(load_config().get('version_variable').split(':')[0]), hide=True) | ||
if add.ok: | ||
run('git commit -m "{}"'.format(version), hide=True) |
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,20 @@ | ||
import configparser | ||
import os | ||
|
||
DEFAULTS = { | ||
'major_tag': ':boom:', | ||
'minor_tag': ':sparkles:', | ||
'patch_tag': ':bug:', | ||
} | ||
|
||
|
||
def load_config(): | ||
config = configparser.ConfigParser() | ||
with open(os.path.join(os.getcwd(), 'setup.cfg')) as f: | ||
config.read_file(f) | ||
settings = {} | ||
settings.update(DEFAULTS) | ||
settings.update(config._sections['semantic_release']) | ||
return settings | ||
|
||
|
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,20 @@ | ||
from unittest import TestCase, mock | ||
from invoke.runner import Result | ||
from semantic_release.git_helpers import get_commit_log, commit_new_version | ||
|
||
|
||
class GetCommitLogTest(TestCase): | ||
def test_first_commit_is_not_initial_commit(self): | ||
self.assertNotEqual(next(get_commit_log()), 'Initial commit') | ||
|
||
|
||
class CommitNewVersionTests(TestCase): | ||
@mock.patch('semantic_release.git_helpers.run', | ||
return_value=Result(stdout='', stderr='', pty='', exited=0)) | ||
def test_add_and_commit(self, mock_run): | ||
commit_new_version('1.0.0') | ||
self.assertEqual( | ||
mock_run.call_args_list, | ||
[mock.call('git add semantic_release/__init__.py', hide=True), | ||
mock.call('git commit -m "1.0.0"', hide=True)] | ||
) |
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,13 @@ | ||
from unittest import TestCase | ||
from semantic_release.settings import load_config | ||
|
||
|
||
class ConfigTests(TestCase): | ||
|
||
def test_load_config(self): | ||
config = load_config() | ||
self.assertIn('version_variable', config) | ||
self.assertIn('major_tag', config) | ||
self.assertIn('minor_tag', config) | ||
self.assertIn('patch_tag', config) | ||
|