Actions
Feature #5687
closedsystem_patches add possibility to add pull-request
Start date:
12/23/2015
Due date:
% Done:
0%
Estimated time:
Plus Target Version:
Release Notes:
Description
Lots of committers use the github editor (including myself).
The edit generates a commit for each file.
So, most of the pull-requests have multiple commits to fix a single issue.
To test these fixes, you now have to add multiple commit-id's to system_patches in order to see it in action.
Would it be a good idea to also allow a PR-url to be added as a patch ?
The github API makes it fairly easy to get all the commit-id's for a single pull-request.
demo code:
<?php
function get_content_from_github($url) {
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,1);
//To comply with https://developer.github.com/v3/#user-agent-required
curl_setopt($ch, CURLOPT_USERAGENT, "nothing");
$content = curl_exec($ch);
curl_close($ch);
return $content;
}
function get_PR_commit_ids_from_github($url)
{
$response=get_content_from_github($url);
$json=json_decode($response, true);
//var_dump($json);
if(!empty($json)) {
foreach($json as $item) {
if(preg_match("/^[0-9a-f]{5,40}$/", $item['sha'])) {
$result[] = $item['sha'];
}
else {
$result = "";
}
}
}
else {
$result = "" ;
}
return $result ;
}
print_r(get_PR_commit_ids_from_github('https://api.github.com/repos/pfsense/pfsense/pulls/2318/commits'));
?>
Actions