Commit 38cd6772 authored by Filippos Giannakos's avatar Filippos Giannakos
Browse files

Ask user before edit changelog

parent e278c46e
......@@ -8,7 +8,8 @@ os.environ["GIT_PYTHON_TRACE"] = "full"
from devflow import utils, versioning
from devflow.version import __version__
from devflow.autopkg import call
from functools import wraps
from devflow.ui import query_action
from functools import wraps, partial
from contextlib import contextmanager
from git.exc import GitCommandError
......@@ -158,7 +159,9 @@ class GitManager(object):
if not feature_upstream in repo.branches:
raise ValueError("Branch %s does not exist." % feature_upstream)
feature_debian = "debian-%s" % feature_upstream
self.edit_changelog(feature_upstream)
action = partial(self.edit_changelog, feature_upstream)
query_action("Edit changelog", action = action)
# self.edit_changelog(feature_upstream)
repo.git.checkout("develop")
with conflicts():
repo.git.merge(feature_upstream)
......
#!/usr/bin/env python
import sys
#http://stackoverflow.com/questions/3041986/python-command-line-yes-no-input
def query_yes_no(question, default="yes"):
"""Ask a yes/no question via raw_input() and return their answer.
"question" is a string that is presented to the user.
"default" is the presumed answer if the user just hits <Enter>.
It must be "yes" (the default), "no" or None (meaning
an answer is required of the user).
The "answer" return value is one of "yes" or "no".
"""
valid = {"yes":True, "y":True, "ye":True,
"no":False, "n":False}
if default == None:
prompt = " [y/n] "
elif default == "yes":
prompt = " [Y/n] "
elif default == "no":
prompt = " [y/N] "
else:
raise ValueError("invalid default answer: '%s'" % default)
while True:
sys.stdout.write(question + prompt)
choice = raw_input().lower()
if default is not None and choice == '':
return valid[default]
elif choice in valid:
return valid[choice]
else:
sys.stdout.write("Please respond with 'yes' or 'no' "\
"(or 'y' or 'n').\n")
def query_action(question, default="yes", action=None):
answer = query_yes_no(question, default)
if answer and action is not None:
action()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment