[meld] maint: Add commit helper and de-command-ify pull



commit c5e472a96fc552d03df3af3e8e23eb0ffe60d276
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sat Aug 23 06:58:43 2014 +1000

    maint: Add commit helper and de-command-ify pull

 maint.py |   29 ++++++++++++++++++++---------
 1 files changed, 20 insertions(+), 9 deletions(-)
---
diff --git a/maint.py b/maint.py
index 1f7f218..f00784f 100755
--- a/maint.py
+++ b/maint.py
@@ -221,10 +221,11 @@ def render_template(template):
 
 
 def call_with_output(
-        cmd, stdin_text=None, echo_stdout=True, abort_on_fail=True):
+        cmd, stdin_text=None, echo_stdout=True, abort_on_fail=True,
+        timeout=10):
     PIPE = subprocess.PIPE
     with subprocess.Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) as proc:
-        stdout, stderr = proc.communicate(stdin_text, timeout=10)
+        stdout, stderr = proc.communicate(stdin_text, timeout=timeout)
     if stdout and echo_stdout:
         click.echo('\n' + stdout.decode('utf-8'))
     if stderr or proc.returncode:
@@ -244,6 +245,23 @@ def check_release_branch():
     return branch
 
 
+def pull():
+    check_release_branch()
+    cmd = ['git', 'pull', '--rebase']
+    call_with_output(cmd, timeout=None)
+
+
+def commit():
+    cmd = ['git', 'diff', 'HEAD']
+    call_with_output(cmd, echo_stdout=True)
+    confirm = click.confirm('\nCommit this change?', default=True)
+    if not confirm:
+        return
+
+    cmd = ['git', 'commit', '-a']
+    call_with_output(cmd, timeout=None)
+
+
 @click.group()
 def cli():
     pass
@@ -276,13 +294,6 @@ def markdown():
 
 
 @cli.command()
-def pull():
-    check_release_branch()
-    cmd = ['git', 'pull', '--rebase']
-    call_with_output(cmd)
-
-
- cli command()
 def dist():
     archive = '%s-%s.tar.bz2' % (meld.conf.__package__, meld.conf.__version__)
     dist_archive_path = os.path.abspath(os.path.join('dist', archive))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]