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
action = partial(self.edit_changelog, feature_upstream)
query_action("Edit changelog", action = action)
# self.edit_changelog(feature_upstream)
with conflicts():
#!/usr/bin/env python
import sys
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] "
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]
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:
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