From: Johannes Quast Date: Mon, 2 Dec 2013 13:47:39 +0000 (+0100) Subject: Add submit text template mechanism X-Git-Tag: 0.20~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9813f9bc33f16b3ab61546d0fd1f5574462bf3c4;p=tools%2Fgbs.git Add submit text template mechanism The text template used by gbs submit can be changed using a special gbs submit template file. Fixes: DEVT-126 Change-Id: Ic9ba27698980ae229431fbbd8c5152297287add5 Signed-off-by: Johannes Quast --- diff --git a/gitbuildsys/cmd_submit.py b/gitbuildsys/cmd_submit.py index 9308d68..89ab530 100644 --- a/gitbuildsys/cmd_submit.py +++ b/gitbuildsys/cmd_submit.py @@ -28,6 +28,24 @@ from gitbuildsys.log import LOGGER as log from gbp.rpm.git import GitRepositoryError, RpmGitRepository +def _lookup_submit_template(): + """ + Look for submit templates in current project, + user and system settings location + """ + + lookup_paths = ( + '.gbs/templates/submit_message', + '~/.gbs/templates/submit_message', + '/etc/gbs/templates/submit_message') + + + for path in lookup_paths: + abs_path = os.path.abspath(os.path.expanduser(path)) + if os.path.exists(abs_path): + return abs_path + + return None def get_message(): @@ -38,6 +56,14 @@ def get_message(): # Please enter the message for your tag. Lines starting with '#' # will be ignored, and an empty message aborts the submission. #''' + + #check for additional submit template + template_path = _lookup_submit_template() + if template_path: + with open(template_path, 'r') as template_file: + submit_template = template_file.read() + prompt = submit_template + raw = edit(prompt) useful = [i for i in raw.splitlines() if not i.startswith('#') ] return os.linesep.join(useful).strip()