Last active
December 20, 2015 05:09
-
-
Save matsubo/6076201 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Create git daily release list group by author | |
* | |
* @author Yuki Matsukura | |
*/ | |
class Git_Daily_List_Customize | |
{ | |
/** @private string of github project url not containing the last slash */ | |
private $github_project_url; | |
/** @private array of author and commit hash */ | |
private $author_to_hash = array(); | |
/** | |
* Constructor | |
* | |
* @param string github project root | |
* @param string output of git daily list | |
*/ | |
public function __construct($github_project_url, $input) | |
{ | |
$this->github_project_url = $github_project_url; | |
foreach (explode("\n", $input) as $line_array) { | |
if (!preg_match('/^\s*([a-z0-9]+) = (.*)$/', $line_array, $match)) { | |
continue; | |
} | |
$this->author_to_hash[$match[2]][] = $match[1]; | |
} | |
} | |
/** | |
* Return string of commits group by author_to_hash | |
* | |
* @return string | |
*/ | |
public function groupByAuthor() | |
{ | |
if (!$this->author_to_hash) { | |
return; | |
} | |
ksort($this->author_to_hash); | |
$line = "List group by author\n"; | |
foreach ($this->author_to_hash as $author => $hash_array) { | |
$line .= sprintf('[] %s', $author); | |
$line .= "\n"; | |
foreach ($hash_array as $hash) { | |
$line .= sprintf(" %s/commit/%s\n", $this->github_project_url, $hash); | |
} | |
$line .= "\n"; | |
} | |
return $line; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment