-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathcli.py
More file actions
41 lines (32 loc) · 1.68 KB
/
cli.py
File metadata and controls
41 lines (32 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Copyright 2019, Oath Inc.
# Licensed under the terms of the Apache 2.0 license. See the LICENSE file in the project root for terms
"""Functions for command script"""
# The logging_basicConfig has to be run before other imports because some modules we use log output on import
# pylint: disable=wrong-import-order, wrong-import-position
from ..screwdriver.environment import logging_basicConfig, update_job_status
logging_basicConfig(check_prefix='VERSION')
import logging
import sys
from .arguments import parse_arguments
from .setup import setupcfg_has_metadata
from .version_types import versioners
LOG_NAME = 'platform_version' if __name__ == '__main__' else __name__
LOG = logging.getLogger(LOG_NAME)
def main():
"""Run the tool from the command line"""
args = parse_arguments()
if args.force_update or setupcfg_has_metadata():
versioner = versioners[args.version_type]
print(f'Updating version using the {versioner.name} version plugin', flush=True)
version = versioner(ignore_meta_version=args.ignore_meta, update_sdv4_meta=args.update_meta, link_to_project=args.link_to_project)
version.update_setup_cfg_metadata()
if args.update_meta:
version.update_meta_version()
update_job_status(status='SUCCESS', message=f'version=={version}')
print(f'Version in setup.cfg and screwdriver v4 metadata package.version updated to: {version}', flush=True)
else:
print(f'Version in setup.cfg updated to: {version}')
else:
print("The 'setup.cfg' file does not have a metadata section with a version in it, not modifying it", file=sys.stderr, flush=True)
if __name__ == '__main__':
main()