[Libreoffice-commits] dev-tools.git: gerritbot/send-daily-digest
Mathias Michel
matm at gmx.fr
Tue Dec 3 01:32:54 PST 2013
gerritbot/send-daily-digest | 46 +++++++++++++++++++++++++++++++-------------
1 file changed, 33 insertions(+), 13 deletions(-)
New commits:
commit b5807dd80ff79305bb01dbd2a5101cef3a2a7864
Author: Mathias Michel <matm at gmx.fr>
Date: Sun Nov 24 02:19:38 2013 +0100
fdo#71911 : show the top level dir of a new change
use the gerrit query to get the info since gerrit does not really create refs
And then we don't have patches in the repo.
(see http://gerrit-documentation.googlecode.com/svn/Documentation/2.3/user-upload.html#_gritty_details)
restore mail for other repos
small format on long lines
Change-Id: Iccce0eb3c1a2c7e17fc6716d61917944ec05d6cf
Reviewed-on: https://gerrit.libreoffice.org/6793
Reviewed-by: Björn Michaelsen <bjoern.michaelsen at canonical.com>
Tested-by: Björn Michaelsen <bjoern.michaelsen at canonical.com>
diff --git a/gerritbot/send-daily-digest b/gerritbot/send-daily-digest
old mode 100644
new mode 100755
index 899fe2e..cf31f98
--- a/gerritbot/send-daily-digest
+++ b/gerritbot/send-daily-digest
@@ -26,24 +26,40 @@ def get_daily_query(status, project):
def get_digest(query):
digest = ''
freshers = ''
+ do_module = []
+ about = ''
# we want first time contributors on new changes for core
- do_fresh = query.split(':')[1].split(' ')[0] == 'core' and \
- query.split(':')[3].split(' ')[0] == 'open' and \
- query.split(':')[3].split(' ')[1] == '-age'
+ do_fresh = (query.split(':')[1].split(' ')[0] == 'core' and
+ query.split(':')[3].split(' ')[0] == 'open' and
+ query.split(':')[3].split(' ')[1] == '-age' )
- if do_fresh: all_users = init_freshers()
+ if do_fresh:
+ all_users = init_freshers()
+ do_module = ['--files', '--patch-sets']
- for line in sh.ssh(args['gerrit'], 'gerrit query --format=JSON -- \'%s\'' % query).encode('utf8').strip().split('\n'):
+ for line in subprocess.check_output(['ssh', args['gerrit'], 'gerrit', 'query'] + do_module +
+ ['--format=JSON','--', "'" + query +"'"]).strip().splitlines():
change = json.loads(line)
if 'url' in change.keys():
+ if do_fresh: # we are in new changes
+ fpaths = (set([fileobj['file'] for pset in change['patchSets']
+ for fileobj in pset['files']]))
+ fpaths.remove('/COMMIT_MSG')
+ # we assume gerrit replies with no leading slash
+ # if no subfolder, module is "build"
+ about = '\n about module ' + ', '.join(sorted(set([p.split('/')[0]
+ if '/' in p else 'build' for p in fpaths])))
+
if do_fresh and change['owner']['name'].encode('utf8') not in all_users:
- freshers += '+ %s\n in %s from %s\n' % (change['subject'][:73], change['url'], change['owner']['name'])
+ freshers += '+ %s\n in %s from %s%s\n' % (change['subject'][:73],
+ change['url'], change['owner']['name'], about)
else:
- digest += '+ %s\n in %s from %s\n' % (change['subject'][:73], change['url'], change['owner']['name'])
+ digest += '+ %s\n in %s from %s%s\n' % (change['subject'][:73],
+ change['url'], change['owner']['name'], about)
if freshers != '':
- digest = '~~~~ First time contributors doing great things ! ~~~~\n' + freshers + \
- "~~~~ End of freshness ~~~~\n\n" + digest
+ digest = ('~~~~ First time contributors doing great things ! ~~~~\n' + freshers +
+ "~~~~ End of freshness ~~~~\n\n" + digest )
if digest == '':
digest = 'None'
return digest
@@ -64,17 +80,20 @@ def init_freshers():
def get_project_body(project):
none = True
- body = '* Open changes on master for project %s changed in the last %d hours:\n\n' % (project, args['age'])
+ body = ('* Open changes on master for project %s changed in the last %d hours:\n\n'
+ % (project, args['age']))
dig = get_digest(get_daily_query('open', project))
if dig != 'None': none = False
body += dig
- body += '\n\n* Merged changes on master for project %s changed in the last %d hours:\n\n' % (project, args['age'])
+ body += ('\n\n* Merged changes on master for project %s changed in the last %d hours:\n\n'
+ % (project, args['age']))
dig = get_digest(get_daily_query('merged', project))
if dig != 'None': none = False
body += dig
- body += '\n\n* Abandoned changes on master for project %s changed in the last %d hours:\n\n' % (project, args['age'])
+ body += ('\n\n* Abandoned changes on master for project %s changed in the last %d hours:\n\n'
+ % (project, args['age']))
dig = get_digest(get_daily_query('abandoned', project))
if dig != 'None': none = False
body += dig
@@ -128,7 +147,7 @@ Note: The bot generating this message can be found and improved here:
msg['X-Mailer'] = 'LibreOfficeGerritDigestMailer 1.1'
server.sendmail(msg_from, msg_to, str(msg))
- server.quit()
+
return project
if __name__ == '__main__':
@@ -147,5 +166,6 @@ if __name__ == '__main__':
send_message_for_project('dev-tools')
else:
send_message_for_project(args['repo'])
+ server.quit()
# vim: set et sw=4 ts=4:
More information about the Libreoffice-commits
mailing list