aboutsummaryrefslogtreecommitdiffstats
path: root/deployment/mgagit
diff options
context:
space:
mode:
authorColin Guthrie <colin@mageia.org>2014-04-21 19:47:51 +0000
committerColin Guthrie <colin@mageia.org>2014-04-21 19:47:51 +0000
commitfb580f0d3c46282175e13adb28ce4d343ff68098 (patch)
treecbf248b7b4fd02f5aec5087fce71d2ff477a4b7e /deployment/mgagit
parent670d69f4019e3e6631fb8067b103e1191b7dd736 (diff)
downloadpuppet-fb580f0d3c46282175e13adb28ce4d343ff68098.tar
puppet-fb580f0d3c46282175e13adb28ce4d343ff68098.tar.gz
puppet-fb580f0d3c46282175e13adb28ce4d343ff68098.tar.bz2
puppet-fb580f0d3c46282175e13adb28ce4d343ff68098.tar.xz
puppet-fb580f0d3c46282175e13adb28ce4d343ff68098.zip
mgagit: Send a second email about any i18n changes to the i18n-reports ML.
After sending the original email, we send a second email to i18n-reports detailing any i18n changes. The method of determining if any changes affect i18n is to look for a folder (or folders) called '.tx' in the tree. If such folders exist, then any changes in their parent folders are considered to be relevent for i18n.
Diffstat (limited to 'deployment/mgagit')
-rwxr-xr-xdeployment/mgagit/templates/git-post-receive-hook102
1 files changed, 97 insertions, 5 deletions
diff --git a/deployment/mgagit/templates/git-post-receive-hook b/deployment/mgagit/templates/git-post-receive-hook
index c33c8a7e..cfa81615 100755
--- a/deployment/mgagit/templates/git-post-receive-hook
+++ b/deployment/mgagit/templates/git-post-receive-hook
@@ -41,6 +41,24 @@ Mageia Git Monkeys.
"""
git_multimail.REVISION_FOOTER_TEMPLATE = git_multimail.FOOTER_TEMPLATE
+I18N_REVISION_HEADER_TEMPLATE = """\
+To: %(recipients)s
+Subject: %(emailprefix)s%(oneline)s
+MIME-Version: 1.0
+Content-Type: text/plain; charset=%(charset)s
+Content-Transfer-Encoding: 8bit
+From: %(fromaddr)s
+Reply-To: %(reply_to)s
+In-Reply-To: %(reply_to_msgid)s
+References: %(reply_to_msgid)s
+X-Git-Repo: %(repo_shortname)s
+X-Git-Refname: %(refname)s
+X-Git-Reftype: %(refname_type)s
+X-Git-Rev: %(rev)s
+Auto-Submitted: auto-generated
+"""
+
+
REPO_NAME_RE = re.compile(r'^/git/(?P<name>.+?)(?:\.git)?$')
def repo_shortname():
basename = os.path.abspath(git_multimail.get_git_dir())
@@ -53,14 +71,15 @@ def repo_shortname():
# Override the Environment class to generate an apporpriate short name which is
# used in git links and as an email prefix
-class LinksEnvironment(git_multimail.Environment):
+class MageiaEnvironment(git_multimail.Environment):
def get_repo_shortname(self):
return repo_shortname()
-git_multimail.Environment = LinksEnvironment
+git_multimail.Environment = MageiaEnvironment
+
# Override the Reviesion class to inject gitweb/cgit links and any referenced
# bug URLs
-class LinksRevision(git_multimail.Revision):
+class MageiaLinksRevision(git_multimail.Revision):
bz = None
def bugzilla_init(self):
@@ -166,7 +185,46 @@ class LinksRevision(git_multimail.Revision):
return output
-git_multimail.Revision = LinksRevision
+# Override the Revision class to inject gitweb/cgit links and any referenced
+# bug URLs
+class MageiaI18NRevision(git_multimail.Revision):
+ """A Change consisting of a single git commit."""
+
+ def __init__(self, reference_change, rev, num, tot):
+ git_multimail.Change.__init__(self, reference_change.environment)
+ self.reference_change = reference_change
+ self.rev = rev
+ self.change_type = self.reference_change.change_type
+ self.refname = self.reference_change.refname
+ self.num = num
+ self.tot = tot
+ self.author = git_multimail.read_git_output(['log', '--no-walk', '--format=%aN <%aE>', self.rev.sha1])
+ self.recipients = False
+ self.output = []
+
+
+ i18n_folders = []
+ # Check files and find i18n folders
+ for line in git_multimail.read_git_lines(['ls-tree', '-rd', self.rev.sha1]):
+ (modetypesha1, name) = line.split("\t", 1)
+ if name.endswith("/.tx"):
+ i18n_folders.append(os.path.dirname(name))
+
+ if len(i18n_folders):
+ self.output = git_multimail.read_git_lines(
+ ['log', '-C', '--stat', '-p', '--no-walk', self.rev.sha1, '--'] + i18n_folders,
+ keepends=True,
+ )
+ if len(self.output):
+ # We have some output so lets send the mail...
+ self.recipients = 'i18n-reports@ml.mageia.org'
+
+ def generate_email_body(self, push):
+ """Show this revision."""
+
+ return self.output
+
+
if __name__ == '__main__':
# Attempt to write a last-updated file for cgit cosmetics
@@ -193,4 +251,38 @@ if __name__ == '__main__':
except Exception:
pass
- git_multimail.main(sys.argv[1:])
+
+ config = git_multimail.Config('multimailhook')
+
+ try:
+ environment = git_multimail.choose_environment(
+ config, osenv=os.environ,
+ )
+
+ mailer = git_multimail.choose_mailer(config, environment)
+ # For testing...
+ #mailer = git_multimail.OutputMailer(sys.stdout)
+
+ changes = []
+ for line in sys.stdin:
+ (oldrev, newrev, refname) = line.strip().split(' ', 2)
+ changes.append(
+ git_multimail.ReferenceChange.create(environment, oldrev, newrev, refname)
+ )
+ push = git_multimail.Push(changes)
+
+
+ # First pass - regular commit mails
+ git_multimail.Revision = MageiaLinksRevision
+ push.send_emails(mailer, body_filter=environment.filter_body)
+
+ # Second pass - i18n commit mails
+ git_multimail.REVISION_HEADER_TEMPLATE = I18N_REVISION_HEADER_TEMPLATE
+ git_multimail.Revision = MageiaI18NRevision
+ # Don't send the summary email, so nuke the change recipients
+ for change in push.changes:
+ change.recipients = False
+ push.send_emails(mailer, body_filter=environment.filter_body)
+
+ except git_multimail.ConfigurationException, e:
+ sys.exit(str(e))