From 442f77df901d46e24abac33a76b99c1fb828638d Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Fri, 9 Jul 2010 16:43:26 -0400 Subject: add git-fpaste --- bin/git-fpaste | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 bin/git-fpaste diff --git a/bin/git-fpaste b/bin/git-fpaste new file mode 100755 index 0000000..d66fc4c --- /dev/null +++ b/bin/git-fpaste @@ -0,0 +1,45 @@ +#!/usr/bin/python + +# Paste a diff using fpaste +# Copyright 2010 Colin Walters +# Licensed under the new-BSD license (http://www.opensource.org/licenses/bsd-license.php) + +import os +import sys +import subprocess +import getopt + +def main(): + try: + opts, args = getopt.getopt(sys.argv[1:], 'd', ['diff']) + except getopt.GetoptError, e: + print unicode(e) + print "Usage: git fpaste [--diff] [REVISION]" + print " If REVISION is not specified it defaults to HEAD." + sys.exit(1) + + if not os.path.exists('/usr/bin/fpaste'): + subprocess.check_call(['pkcon', 'install', 'fpaste']) + + diff = False + for o, a in opts: + if o in ('--diff', ): + diff = True + + if len(args) > 0: + revision = args[0] + else: + revision = 'HEAD^' + + if diff: + proc = subprocess.Popen(['git', 'diff'], stdout=subprocess.PIPE, stderr=sys.stderr) + description = "diff from " + os.path.basename(os.getcwd()) + else: + proc = subprocess.Popen(['git', 'format-patch', '--stdout', revision], stdout=subprocess.PIPE, stderr=sys.stderr) + description = revision + " in " + os.path.basename(os.getcwd()) + pasteproc = subprocess.Popen(['fpaste', '-d', description], stdin=proc.stdout, stdout=sys.stdout, stderr=sys.stderr) + pasteproc.wait() + +if __name__ == '__main__': + main() + -- cgit