Created
June 24, 2011 08:48
-
-
Save co3k/1044456 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 | |
$url = 'http://redmine.openpne.jp/versions/show/165'; | |
function getCommitHashList($path) | |
{ | |
$url = 'http://redmine.openpne.jp'.$path; | |
$text = file_get_contents($url); | |
preg_match_all('#/projects/op3/repository/revisions/([a-z0-9]+)#', $text, $matches); | |
return array_unique($matches[1]); | |
} | |
$document = new DOMDocument(); | |
$document->loadHTMLFile($url); | |
foreach ($document->getElementsByTagName('a') as $node) { | |
if (false !== strpos($node->getAttribute('class'), 'issue status')) { | |
foreach (getCommitHashList($node->getAttribute('href')) as $hash) { | |
echo $hash.PHP_EOL; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment