From eab0401e74087002c67d0224e8426c9162680cce Mon Sep 17 00:00:00 2001
From: Zhiming Wang <zmwangx@gmail.com>
Date: Mon, 25 Jan 2016 14:01:50 -0800
Subject: pyblog: Allow opening interactive shell when deploying

This almost always happens when I gendeploy: gen asks me to touch the
new post which I agree, but then the project root is dirty and I'm
greeted with the continue or not prompt, at which point I have no choice
but to open a new shell (or ^Z suspend the current job) to commit the
changes.

This commit allows to open an interactive shell in place when project
root is found to be dirty when deploying, which nicely solves the issue.

Closes #10.
---
 pyblog | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/pyblog b/pyblog
index 31b72c91..10cde721 100755
--- a/pyblog
+++ b/pyblog
@@ -1007,10 +1007,11 @@ def deploy(args):
                          "to the source branch, since the SHA and title "
                          "of the latest commit on the source branch will be "
                          "incorporated into the commit message on "
-                         "the deployment branch.\n")
+                         "the deployment branch. Type s[hell] on the "
+                         "next prompt to open an interactive shell.\n")
         sys.stderr.write(RESET)
         while True:
-            sys.stderr.write("Continue? [yN] ")
+            sys.stderr.write("Continue? [yNs] ")
             answer = input()
             if not answer:
                 # default
@@ -1022,6 +1023,15 @@ def deploy(args):
             elif answer.startswith(('n', 'N')):
                 abort = True
                 break
+            elif answer.startswith(('s', 'S')):
+                shell = (os.environ['SHELL'] if 'SHELL' in os.environ and os.environ['SHELL']
+                         else 'zsh')
+                subprocess.call(shell)
+                stilldirty = subprocess.check_output(["git", "status", "--porcelain"])
+                if stilldirty:
+                    sys.stderr.write(YELLOW)
+                    sys.stderr.write("Project root is still dirty.\n")
+                    sys.stderr.write(RESET)
             else:
                 sys.stderr.write("Please answer yes or no.\n")
         if abort:
-- 
cgit v1.2.1