Permalink
Browse files

add support to email patch to 'koha-patches' mailing-list, using --ma…

…il arg
  • Loading branch information...
1 parent 723b7ff commit 41ab6baae17a3f9cbd6bfa2c529d0b6893d431bc @KohaAloha committed Sep 25, 2012
Showing with 28 additions and 2 deletions.
  1. +28 −2 git-bz
View
@@ -85,6 +85,11 @@ import urlparse
from xml.etree.cElementTree import ElementTree
import base64
+import smtplib
+import random
+import string
+
+
# Globals
# =======
@@ -1015,6 +1020,7 @@ def get_bug_server(host, path, https, auth_user, auth_password, bz_user, bz_pass
return servers[identifier]
+
# Unfortunately, Bugzilla doesn't set a useful status code for
# form posts. Because it's very confusing to claim we succeeded
# but not, we look for text in the response indicating success,
@@ -1184,7 +1190,6 @@ class Bug(object):
fields['obsolete'] = map(str, obsoletes)
files = { 'data': (filename, 'text/plain', data) }
-
response = self.server.send_post("/attachment.cgi", fields, files)
response_data = response.read()
if not check_for_success(response, response_data,
@@ -1197,6 +1202,19 @@ class Bug(object):
print "Attached %s" % filename
+ if global_options.mail:
+ N=6
+ tempfile = ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(N))
+ f = open('/tmp/'+tempfile, 'w')
+ f.write(data)
+ f.close()
+ mlist = "koha-patches@lists.koha-community.org"
+ str1 = "git send-email --quiet --confirm never --to '" + mlist +"' /tmp/"+tempfile
+
+ import os
+ retvalue = os.system(str1)
+ print retvalue
+
# Update specified fields of a bug; keyword arguments are interpreted
# as field_name=value
def update(self, **changes):
@@ -2084,6 +2102,10 @@ def add_edit_option():
parser.add_option("-e", "--edit", action="store_true",
help="allow editing the bugzilla comment")
+def add_mail_option():
+ parser.add_option("-m", "--mail", action="store_true",
+ help="send email")
+
def add_fix_option():
parser.add_option("", "--fix", metavar="<bug reference>",
help="attach commits and close bug")
@@ -2095,12 +2117,15 @@ elif command == 'apply':
parser.set_usage("git bz apply [options] <bug reference>");
add_add_url_options()
min_args = max_args = 1
+
elif command == 'attach':
parser.set_usage("git bz attach [options] [<bug reference>] (<commit> | <revision range>)");
add_add_url_options()
add_edit_option()
+ add_mail_option()
min_args = 1
- max_args = 2
+ max_args = 3
+
elif command == 'edit':
parser.set_usage("git bz edit [options] (<bug reference> | <commit> | <revision range>)");
parser.add_option("", "--pushed", action="store_true",
@@ -2140,6 +2165,7 @@ elif command == 'apply':
do_apply(*args)
elif command == 'attach':
do_attach(*args)
+
elif command == 'edit':
if global_options.pushed:
exit

0 comments on commit 41ab6ba

Please sign in to comment.