phpBB

Development Discussion Board

phpBB's testing ground of bleeding edge code
Advanced search

Commit Emails

Discuss general development subjects that are not specific to a particular version like the versioning control system we use or other infrastructure.

Commit Emails

Postby MichaelC » Fri Mar 09, 2012 5:04 pm

I was discussing this with imkingdavid a minute ago and I came up with an idea:

Problem
At the moment an email is sent out for each commit. When there is a PR with lots of commits a lot of emails get sent out.
With the AJAX PR about 100 emails will be sent out.

Suggestion:
Change it so its 1 email per push, not per commit. That means it is 1 email for develop changes. 2 for develop-olympus changes.

Then all commits would be detailed seperately in the email. So something like:

[phpBB Commits][phpbb3] David King pushed to the develop branch.
-------Commit 1 Info---------
Commit 1 Changes
-------Commit 2 Info----------
Commit 2 Changes
Unknown Bliss
psoTFX wrote:I went with Olympus because as I said to the teams ... "It's been one hell of a hill to climb"

No unsolicited PMs please except for quotes.
User avatar
MichaelC
Website Team
Website Team
 
Posts: 798
Joined: Thu Jan 28, 2010 6:29 pm

Re: Commit Emails

Postby callumacrae » Fri Mar 09, 2012 6:10 pm

+1
"In JavaScript, there is a beautiful, elegant, highly expressive language that is buried under a steaming pile of good intentions and blunders"
—Douglas Crockford

View my MOD, phpBB Mobile
User avatar
callumacrae
Website Team
Website Team
 
Posts: 883
Joined: Tue Apr 27, 2010 9:37 am
Location: England

Re: Commit Emails

Postby Oleg » Sat Mar 10, 2012 12:27 am

Are those emails for git commits or svn commits?
Oleg
 
Posts: 1150
Joined: Tue Feb 23, 2010 2:38 am

Re: Commit Emails

Postby DavidIQ » Sat Mar 10, 2012 1:59 am

Git commits. And it's not as easy as you're making it seem. We don't store when we send out these emails. Some sort of data backed would need to be put in place, be it by way of a file or database, along with logic that would use it. The multiple emails are triggered by github themselves, not the script we use to send out the emails.
Image
User avatar
DavidIQ
MOD Team Leader
MOD Team Leader
 
Posts: 772
Joined: Thu Mar 02, 2006 4:29 pm
Location: Earth

Re: Commit Emails

Postby MichaelC » Sat Mar 10, 2012 7:58 am

Well the email github service hook sends out 1 email per push but the emails don't nearly as nice.

A service hook runs after a push, not a commit (as far as I know).
Unknown Bliss
psoTFX wrote:I went with Olympus because as I said to the teams ... "It's been one hell of a hill to climb"

No unsolicited PMs please except for quotes.
User avatar
MichaelC
Website Team
Website Team
 
Posts: 798
Joined: Thu Jan 28, 2010 6:29 pm

Re: Commit Emails

Postby callumacrae » Sat Mar 10, 2012 8:28 am

Unknown Bliss wrote:Well the email github service hook sends out 1 email per push but the emails don't nearly as nice.

A service hook runs after a push, not a commit (as far as I know).

Correct: http://help.github.com/post-receive-hooks/
"In JavaScript, there is a beautiful, elegant, highly expressive language that is buried under a steaming pile of good intentions and blunders"
—Douglas Crockford

View my MOD, phpBB Mobile
User avatar
callumacrae
Website Team
Website Team
 
Posts: 883
Joined: Tue Apr 27, 2010 9:37 am
Location: England

Re: Commit Emails

Postby MichaelC » Sat Mar 10, 2012 8:31 am

callumacrae wrote:
Unknown Bliss wrote:Well the email github service hook sends out 1 email per push but the emails don't nearly as nice.

A service hook runs after a push, not a commit (as far as I know).

Correct: http://help.github.com/post-receive-hooks/


In that case could a script be built to send out the emails with the information received from POST when that happens?
Unknown Bliss
psoTFX wrote:I went with Olympus because as I said to the teams ... "It's been one hell of a hill to climb"

No unsolicited PMs please except for quotes.
User avatar
MichaelC
Website Team
Website Team
 
Posts: 798
Joined: Thu Jan 28, 2010 6:29 pm

Re: Commit Emails

Postby DavidIQ » Sat Mar 10, 2012 12:36 pm

Well knock yourselves out then. There is no recursion in the code so somehow the commit is what is generating the multiple emails.
Code: Select all
#!/usr/bin/php-cgi
<?php

//Set the notification email to be used throughout the script
$notify_email = 'management@phpbb.com';

//Get the git payload
$payload = $_POST['payload'];

if (empty($payload))
{
   @mail($notify_email, 'payload empty', print_r($GLOBALS, true));
   exit;
}

$payload = trim(stripslashes($payload));
$payload = json_decode($payload);

if (!$payload || !is_object($payload))
{
   @mail($notify_email, 'payload wrong', print_r($GLOBALS, true));
   exit;
}

$before = $payload->before;
$ref = $payload->ref;
$after = $payload->after;
$repository = $payload->repository->name;

// Check repository name
$config_name = 'git-notifier-' . $repository . '.yml';

if (!@file_exists('/etc/redmine/git/' . $config_name))
{
   @mail($notify_email, 'wrong repository', print_r($GLOBALS, true));
   exit;
}

// Let's collect some additional information...
$bare_command = 'git-commit-notifier /etc/redmine/git/' . $config_name . ' ' . $before . ' ' . $after . ' ' . $ref;
$repository_path = '/git/' . $repository . '.git';
$git_pull_command = '/etc/redmine/git/git_pull_one_repo.sh ' . $repository . '.git 2>&1 >> /var/log/redmine/git_pull_' . $repository . '.log';
$git_pull_user = 'www-data';
$notifier_logfile = '/var/log/redmine/git-commit-notifier_' . $repository . '.log';

// Pull repository, we need the correct information
$result = trim(`$git_pull_command`);
sleep(2);

// Note command to be issued in log
$command = 'echo "[' . date('Y-m-d H:i:s') . '] Calling: ' . $bare_command . '" >> ' . $notifier_logfile;
$result = trim(`$command`);

// Now call git commit notifier
$command = 'cd ' . $repository_path . ' && ' . $bare_command . ' >> ' . $notifier_logfile . ' 2>&1';
$result = trim(`$command`);
Image
User avatar
DavidIQ
MOD Team Leader
MOD Team Leader
 
Posts: 772
Joined: Thu Mar 02, 2006 4:29 pm
Location: Earth

Re: Commit Emails

Postby MichaelC » Sat Mar 10, 2012 12:46 pm

DavidIQ wrote:Well knock yourselves out then. There is no recursion in the code so somehow the commit is what is generating the multiple emails.


I'll have a look at it later on. :)
Unknown Bliss
psoTFX wrote:I went with Olympus because as I said to the teams ... "It's been one hell of a hill to climb"

No unsolicited PMs please except for quotes.
User avatar
MichaelC
Website Team
Website Team
 
Posts: 798
Joined: Thu Jan 28, 2010 6:29 pm

Re: Commit Emails

Postby callumacrae » Sat Mar 10, 2012 1:23 pm

git-commit-notifier splits them up.
"In JavaScript, there is a beautiful, elegant, highly expressive language that is buried under a steaming pile of good intentions and blunders"
—Douglas Crockford

View my MOD, phpBB Mobile
User avatar
callumacrae
Website Team
Website Team
 
Posts: 883
Joined: Tue Apr 27, 2010 9:37 am
Location: England

Next

Return to General Development Discussion

Who is online

Users browsing this forum: No registered users and 4 guests