Skip to content

Commit f457cf5

Browse files
committedDec 9, 2014
Store additional context
1 parent facba40 commit f457cf5

File tree

5 files changed

+33
-3
lines changed

5 files changed

+33
-3
lines changed
 

‎changes/changelog.py

+1
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,4 @@ def generate_changelog(context):
8787
dry_run=context.dry_run
8888
)
8989
log.info('Added content to CHANGELOG.md')
90+
context.changelog_content = changelog_content

‎changes/config.py

+25-1
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,23 @@
33
import click
44
from giturlparse import parse
55
from plumbum.cmd import git
6+
from plumbum import local
67
import yaml
78

89
CONFIG_FILE = '.changes'
910
DEFAULTS = {
1011
'changelog': 'CHANGELOG.md',
1112
'readme': 'README.md',
13+
'gh_token': None,
1214
}
1315

1416

1517
class CLI(object):
1618
test_command = None
1719
pypi = None
1820
skip_changelog = None
21+
changelog_content = None
22+
parsed_repo = None
1923

2024
def __init__(self, module_name, dry_run, debug, no_input, requirements,
2125
new_version, current_version, repo_url, version_prefix):
@@ -32,8 +36,28 @@ def __init__(self, module_name, dry_run, debug, no_input, requirements,
3236
self.current_version = current_version
3337
self.repo_url = repo_url
3438

35-
self.parsed_repo = parse(git('config --get remote.origin.url'.split(' ')))
3639

40+
@property
41+
def repo(self):
42+
return self.parsed_repo.repo
43+
44+
@property
45+
def owner(self):
46+
return self.parsed_repo.owner
47+
48+
@property
49+
def github(self):
50+
return self.parsed_repo.github
51+
52+
@property
53+
def bitbucket(self):
54+
return self.parsed_repo.bitbucket
55+
56+
57+
@property
58+
def parsed_repo(self):
59+
with local.cwd(local.cwd / self.module_name):
60+
return parse(git('config --get remote.origin.url'.split(' ')))
3761

3862
@property
3963
def repo(self):

‎tests/__init__.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
module_name = 'test_app'
1212
context = CLI(module_name, True, True, True, '%s/requirements.txt' % module_name, '0.0.2', '0.0.1', 'https://github.com/someuser/test_app', None)
13+
context.gh_token = 'foo'
1314
context.requirements = '%s/requirements.txt' % module_name
1415
context.tmp_file = '%s/__init__.py' % module_name
1516
context.initial_init_content = [
@@ -31,8 +32,10 @@ def setup():
3132
with open(context.requirements, 'w') as req_file:
3233
req_file.write('pytest')
3334

34-
with local.cwd(local.cwd / module_name):
35-
git('init', module_name)
35+
with local.cwd(local.cwd / context.module_name):
36+
git('init')
37+
git('remote', 'add', 'origin', 'https://github.com/michaeljoseph/test_app.git')
38+
3639

3740
def teardown():
3841
if os.path.exists(context.tmp_file):

‎tests/test_changelog.py

+1
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,4 @@ def test_replace_sha_with_commit_link():
4545

4646
def test_generate_changelog():
4747
changelog.generate_changelog(context)
48+
assert isinstance(context.changelog_content, list)

‎tests/test_config.py

+1
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,6 @@ def test_malformed_config_returns_none():
2727

2828
def test_parsed_repo_url():
2929
assert context.owner == 'michaeljoseph'
30+
assert context.repo == 'test_app'
3031
assert context.github
3132
assert not context.bitbucket

0 commit comments

Comments
 (0)