diff options
-rw-r--r-- | raw_post | 42 |
1 files changed, 23 insertions, 19 deletions
@@ -32,26 +32,30 @@ if "--unpack" in sys.argv: print "Unpack only" raise SystemExit -title = raw_input ("Post title ? ") -editor = "vi" -if "VISUAL" in os.environ: - editor = os.environ["VISUAL"] -elif "EDITOR" in os.environ: - editor = os.environ["EDITOR"] - -contents_path = os.path.join (repo, CONTENTS_FILE) - -ret = subprocess.call ([editor, contents_path]) -if ret == 0: - contents = open (contents_path).read () - os.remove (contents_path) +if "--raw" in sys.argv: + p = subprocess.Popen (["git", "commit", "--allow-empty"]) + p.communicate () else: - print "A problem occured while editing the contents file" - raise SystemExit - -p = subprocess.Popen (["git", "commit", "--allow-empty", "-F", "-"], - stdin = subprocess.PIPE) -p.communicate ("%s\n\n%s" % (title, contents)) + title = raw_input ("Post title ? ") + editor = "vi" + if "VISUAL" in os.environ: + editor = os.environ["VISUAL"] + elif "EDITOR" in os.environ: + editor = os.environ["EDITOR"] + + contents_path = os.path.join (repo, CONTENTS_FILE) + + ret = subprocess.call ([editor, contents_path]) + if ret == 0: + contents = open (contents_path).read () + os.remove (contents_path) + else: + print "A problem occured while editing the contents file" + raise SystemExit + + p = subprocess.Popen (["git", "commit", "--allow-empty", "-F", "-"], + stdin = subprocess.PIPE) + p.communicate ("%s\n\n%s" % (title, contents)) if p.returncode == 0: print "New post successfully added" else: |