Commit: 01fda1b87d24f4e1a51c4ca7c6f55a60f63c4ab2 Author: Derick Rethans(git...@derickrethans.nl) Tue, 20 Mar 2012 09:04:29 +0000 Committer: Derick Rethans(git...@derickrethans.nl) Tue, 20 Mar 2012 09:05:42 +0000 Parents: f05ac19fc6481815958655f483ef8d0d4fbc3bbe
Link: http://git.php.net/?p=karma.git;a=commitdiff;h=01fda1b87d24f4e1a51c4ca7c6f55a60f63c4ab2 Log: Use the author/tagged date as timestamp to go into the e-mail header. This makes the emails appear in chronological order in the threads. Changed paths: M lib/Git/PostReceiveHook.php M lib/Mail.php Diff: 01fda1b87d24f4e1a51c4ca7c6f55a60f63c4ab2 diff --git a/lib/Git/PostReceiveHook.php b/lib/Git/PostReceiveHook.php index 6fd1a2f..60c0a33 100644 --- a/lib/Git/PostReceiveHook.php +++ b/lib/Git/PostReceiveHook.php @@ -258,6 +258,7 @@ class PostReceiveHook extends ReceiveHook $shortname = str_replace('refs/tags/', '', $name); $mail = new \Mail(); $mail->setSubject($this->emailPrefix . 'tag ' . $this->getRepositoryShortName() . ': ' . $status[$changeType] . ' tag ' . $shortname); + $mail->setTimestamp(strtotime($info['tagger_date'])); $message = 'Tag ' . $shortname . ' in ' . $this->getRepositoryName() . ' was ' . $status[$changeType] . 'd' . (($changeType != self::TYPE_CREATED) ? ' from ' . $oldrev : '' ) . "\n"; @@ -501,6 +502,7 @@ class PostReceiveHook extends ReceiveHook $mail = new \Mail(); $mail->setSubject($this->emailPrefix . 'com ' . $this->getRepositoryShortName() . ': ' . $info['subject'] . ': '. implode(' ', array_keys($paths))); + $mail->setTimestamp(strtotime($info['author_date'])); $message = ''; diff --git a/lib/Mail.php b/lib/Mail.php index 15b90e8..7c63a41 100644 --- a/lib/Mail.php +++ b/lib/Mail.php @@ -12,6 +12,7 @@ class Mail private $boundary = ''; private $uniqId = ''; private $replyTo = []; + private $timestamp = null; const CRLF = "\r\n"; @@ -100,6 +101,15 @@ class Mail } /** + * Set timestamp + * @param string $timestamp timestamp + */ + public function setTimestamp($timestamp) + { + $this->timestamp = trim($timestamp); + } + + /** * Set mail body text * @param string $message body text */ @@ -157,7 +167,7 @@ class Mail $headers[] = $this->makeHeader('In-Reply-To', $replyTo); } $headers[] = $this->makeHeader('MIME-Version', '1.0'); - $headers[] = $this->makeHeader('Date', date(DATE_RFC2822, time())); + $headers[] = $this->makeHeader('Date', date(DATE_RFC2822, $this->timestamp ?: time())); if ($this->multipart) { $this->boundary = sha1($this->uniqId); $headers[] = $this->makeHeader('Content-Type', 'multipart/mixed; boundary="' . $this->boundary . '"'); @@ -212,4 +222,4 @@ class Mail return mail($receivers, $subject, $body, $headers); } -} \ No newline at end of file +} -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php