dry_run = False
redmine = None
bri_tag = None
+github_token_file = "~/.github_token"
github_token = None
+redmine_key_file = "~/.redmine_key"
+redmine_key = None
def browser_running():
global browser_cmd
return '{}..HEAD'.format(commit)
def connect_to_redmine(a):
- if a.key:
- logging.info("Redmine key was provided; using it")
- return Redmine(redmine_endpoint, key=a.key)
- elif a.user and a.password:
+ global redmine_key
+ global redmine_key_file
+ redmine_key = read_from_file(redmine_key_file)
+ if a.user and a.password:
logging.info("Redmine username and password were provided; using them")
return Redmine(redmine_endpoint, username=a.user, password=a.password)
+ elif redmine_key:
+ logging.info("Redmine key was read from '%s'; using it" % redmine_key_file)
+ return Redmine(redmine_endpoint, key=redmine_key)
else:
usage()
def parse_arguments():
parser = argparse.ArgumentParser()
- parser.add_argument("--key", help="Redmine user key")
parser.add_argument("--user", help="Redmine user")
parser.add_argument("--password", help="Redmine password")
- parser.add_argument("--token", help="GitHub token")
parser.add_argument("--debug", help="Show debug-level messages",
action="store_true")
parser.add_argument("--dry-run", help="Do not write anything to Redmine",
tag_sha1(repo, sha1)
return True
+def read_from_file(fs):
+ retval = None
+ full_path=os.path.expanduser(fs)
+ try:
+ with open(full_path, "r") as f:
+ retval = f.read().strip()
+ except FileNotFoundError:
+ pass
+ return retval
+
def releases():
return ('argonaut', 'bobtail', 'cuttlefish', 'dumpling', 'emperor',
'firefly', 'giant', 'hammer', 'infernalis', 'jewel', 'kraken',
if a.no_browser:
no_browser = True
logging.warning("Web browser will not be used even if it is running")
- if a.token:
- github_token = a.token
- logging.info("GitHub token provided on command line; using it")
+ if github_token:
+ logging.info("GitHub token was read from '%s'; using it" % github_token_file)
def set_logging_level(a):
if a.debug:
'v12.2': 'luminous', 'v13.2': 'mimic', 'v14.2': 'nautilus'}
def usage():
- logging.error("Command-line arguments must include either a Redmine key (--key) "
+ logging.error("Redmine credentials are required to perform this operation. "
+ "Please provide either a Redmine key (via %s) "
"or a Redmine username and password (via --user and --password). "
"Optionally, one or more issue numbers can be given via positional "
"argument(s). In the absence of positional arguments, the script "
"will loop through all merge commits after the tag \"BRI-{release}\". If there "
- "is no such tag in the local branch, one will be created for you.")
+ "is no such tag in the local branch, one will be created for you." % redmine_key_file)
exit(-1)
args = parse_arguments()
set_logging_level(args)
logging.debug(args)
+ github_token = read_from_file(github_token_file)
report_params(args)
#
# set up Redmine variables