Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Narvaez <dwnarvaez@gmail.com>2012-06-25 22:36:12 (GMT)
committer Daniel Narvaez <dwnarvaez@gmail.com>2012-06-25 22:36:12 (GMT)
commit325906007853b67b21adbef8f6caa93c64ba38f5 (patch)
treebd6b452708ac14c6557334b9974b3959cfe726eb
parent2a732af9524920f61bb7a5920298d7f65df94b36 (diff)
Add a script to streamline patch submission
Needs work.
-rw-r--r--Makefile4
-rwxr-xr-xscripts/shell/send-patches99
2 files changed, 102 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 902a10b..d80a097 100644
--- a/Makefile
+++ b/Makefile
@@ -47,7 +47,9 @@ run:
xinit $(SCRIPTS)/xinitrc -- :99
shell:
- @PS1="[sugar-build]$$ " $(JHBUILD) shell
+ @PS1="[sugar-build]$$ " \
+ PATH=$(PATH):$(SCRIPTS)/shell \
+ $(JHBUILD) shell
bug-report:
@$(SCRIPTS)/bug-report
diff --git a/scripts/shell/send-patches b/scripts/shell/send-patches
new file mode 100755
index 0000000..62c1519
--- /dev/null
+++ b/scripts/shell/send-patches
@@ -0,0 +1,99 @@
+#!/usr/bin/python
+
+import argparse
+import re
+import subprocess
+import sys
+
+GIT_CONFIG_SETUP = "sugar-build.send-patches.setup"
+
+def get_git_config(name, is_global=False):
+ args = ["git", "config"]
+
+ if is_global:
+ args.append("--global")
+
+ args.append(name)
+
+ try:
+ return subprocess.check_output(args)
+ except subprocess.CalledProcessError:
+ return None
+
+def set_git_config(name, value):
+ return subprocess.check_output(["git", "config", name, value])
+
+def unset_git_config(name):
+ try:
+ subprocess.check_output(["git", "config", "--unset", name])
+ return True
+ except subprocess.CalledProcessError:
+ return False
+
+def get_from():
+ name = get_git_config("user.name", is_global=True)
+ email = get_git_config("user.email", is_global=True)
+
+ if not name or not email:
+ print "Please configure your name and email\n\n" \
+ "git config --global user.name Your Name\n" \
+ "git config --global user.email youremail@example.com"
+ sys.exit(1)
+
+ return "%s <%s>" % (name, email)
+
+def get_module():
+ for line in open("configure.ac"):
+ m = re.match("AC_INIT\((.+)\)", line)
+ if m:
+ return m.group(1).split(",")[-1][1:-1]
+
+def setup():
+ print "Choose how to send email \n\n" \
+ "1 Google account\n" \
+ "2 Sugar Labs shell account\n" \
+ "3 System sendmail"
+
+ choice = None
+
+ while choice not in ["1", "2", "3"]:
+ choice = raw_input("# ")
+
+ if choice == "1":
+ print "\nEnter your user name"
+ smtpuser = raw_input("# ")
+
+ set_git_config("sendemail.smtpencryption", "tls")
+ set_git_config("sendemail.smtpserver", "smtp.gmail.com")
+ set_git_config("sendemail.smtpserverport", "587")
+ set_git_config("sendemail.smtpuser", smtpuser)
+ elif choice == "2":
+ print "\nEnter your user name"
+ smtpuser = raw_input("# ")
+
+ set_git_config("sendemail.smtpencryption", "tls")
+ set_git_config("sendemail.smtpserver", "smtp.sugarlabs.org")
+ set_git_config("sendemail.smtpserverport", "587")
+ set_git_config("sendemail.smtpuser", smtpuser)
+ elif choice == "3":
+ unset_git_config("sendemail.smtpencryption")
+ unset_git_config("sendemail.smtpserver")
+ unset_git_config("sendemail.smtpserverport")
+ unset_git_config("sendemail.smtpuser")
+
+ set_git_config(GIT_CONFIG_SETUP, "true")
+
+parser = argparse.ArgumentParser()
+parser.add_argument("--setup", action="store_true",
+ help="interactive configuration")
+
+args = parser.parse_args()
+
+if not get_git_config(GIT_CONFIG_SETUP) or args.setup:
+ setup()
+
+subprocess.call(["git", "send-email",
+ "-from", get_from(),
+ "-to", "sugar-devel <sugar-devel@lists.sugarlabs.org>",
+ "--subject-prefix", "PATCH %s" % get_module(),
+ "origin"])