1
|
|
|
import contextlib |
2
|
|
|
import os |
3
|
|
|
|
4
|
|
|
import click |
|
|
|
|
5
|
|
|
import requests_cache |
|
|
|
|
6
|
|
|
|
7
|
|
|
from . import __version__ |
8
|
|
|
from changes.commands import init as init_command |
9
|
|
|
from changes.commands import status as status_command |
10
|
|
|
from changes.commands import stage as stage_command |
|
|
|
|
11
|
|
|
|
12
|
|
|
VERSION = 'changes {}'.format(__version__) |
13
|
|
|
|
14
|
|
|
|
15
|
|
|
@contextlib.contextmanager |
16
|
|
|
def work_in(dirname=None): |
17
|
|
|
""" |
18
|
|
|
Context manager version of os.chdir. When exited, returns to the working |
19
|
|
|
directory prior to entering. |
20
|
|
|
""" |
21
|
|
|
curdir = os.getcwd() |
22
|
|
|
try: |
23
|
|
|
if dirname is not None: |
24
|
|
|
os.chdir(dirname) |
25
|
|
|
yield |
26
|
|
|
finally: |
27
|
|
|
os.chdir(curdir) |
28
|
|
|
|
29
|
|
|
|
30
|
|
|
def print_version(context, param, value): |
31
|
|
|
if not value or context.resilient_parsing: |
32
|
|
|
return |
33
|
|
|
click.echo(VERSION) |
34
|
|
|
context.exit() |
35
|
|
|
|
36
|
|
|
|
37
|
|
|
@click.option( |
38
|
|
|
'--dry-run', |
39
|
|
|
help='Prints (instead of executing) the operations to be performed.', |
40
|
|
|
is_flag=True, |
41
|
|
|
default=False, |
42
|
|
|
) |
43
|
|
|
@click.option( |
44
|
|
|
'--verbose', |
45
|
|
|
help='Enables verbose output.', |
46
|
|
|
is_flag=True, |
47
|
|
|
default=False, |
48
|
|
|
) |
49
|
|
|
@click.version_option( |
50
|
|
|
__version__, |
51
|
|
|
'-V', |
52
|
|
|
'--version', |
53
|
|
|
message=VERSION |
54
|
|
|
) |
55
|
|
|
@click.group( |
56
|
|
|
context_settings=dict( |
57
|
|
|
help_option_names=[u'-h', u'--help'] |
58
|
|
|
), |
59
|
|
|
) |
60
|
|
|
def main(dry_run, verbose): |
61
|
|
|
"""Ch-ch-changes""" |
62
|
|
|
|
63
|
|
|
|
64
|
|
|
@click.command() |
65
|
|
|
@click.argument('repo_directory', required=False) |
66
|
|
|
def status(repo_directory): |
67
|
|
|
""" |
68
|
|
|
Shows current project release status. |
69
|
|
|
""" |
70
|
|
|
repo_directory = repo_directory if repo_directory else '.' |
71
|
|
|
|
72
|
|
|
with work_in(repo_directory): |
73
|
|
|
requests_cache.configure() |
74
|
|
|
init_command.init() |
75
|
|
|
status_command.status() |
76
|
|
|
|
77
|
|
|
main.add_command(status) |
78
|
|
|
|
79
|
|
|
|
80
|
|
|
@click.command() |
81
|
|
|
@click.option( |
82
|
|
|
'--draft', |
83
|
|
|
help='Enables verbose output.', |
84
|
|
|
is_flag=True, |
85
|
|
|
default=False, |
86
|
|
|
) |
87
|
|
|
@click.argument('repo_directory', required=False) |
88
|
|
|
@click.argument('release_name', required=False) |
89
|
|
|
@click.argument('release_description', required=False) |
90
|
|
|
def stage(draft, repo_directory, release_name, release_description): |
91
|
|
|
""" |
92
|
|
|
Stages a release |
93
|
|
|
""" |
94
|
|
|
with work_in(repo_directory): |
95
|
|
|
requests_cache.configure(expire_after=60*10*10) |
96
|
|
|
init_command.init() |
97
|
|
|
stage_command.stage(draft, release_name, release_description) |
98
|
|
|
|
99
|
|
|
main.add_command(stage) |
100
|
|
|
|
This can be caused by one of the following:
1. Missing Dependencies
This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.
2. Missing __init__.py files
This error could also result from missing
__init__.py
files in your module folders. Make sure that you place one file in each sub-folder.