Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Bouke/388760 to your computer and use it in GitHub Desktop.
Save Bouke/388760 to your computer and use it in GitHub Desktop.
import issues from flyspray into github
<?php
/**
* Example database from flyspray
*
* @author Bouke Haarsma <bouke@webatoom.nl>
*/
mysql_connect("localhost", "(user)", "(pass)");
mysql_select_db("(db)");
$tasks = mysql_query("SELECT `task_id`, `item_summary`, `detailed_desc` FROM `tasks` WHERE `project_id` = 7 AND `is_closed` = 0 ORDER BY `date_opened` DESC");
while ($task = mysql_fetch_assoc($tasks)) {
$comments = mysql_query("SELECT `comment_text` FROM `comments` WHERE `task_id` = {$task['task_id']}");
echo "Posting {$task['task_id']}...\n";
$issue = json_decode(file_get_contents("https://github.com/api/v2/json/issues/open/:user/:repo",
false, stream_context_create(array(
"http" => array(
"method" => "POST",
'header' => sprintf("Authorization: Basic %s\r\n", base64_encode("(user):(pass)")).
"Content-type: application/x-www-form-urlencoded\r\n",
'content' => http_build_query(array("title" => htmlentities($task['item_summary']), "body" => htmlentities($task['detailed_desc']))),
)
))));
sleep(1);
while ($comment = mysql_fetch_assoc($comments)) {
echo "Posting comment...\n";
json_decode(file_get_contents("https://github.com/api/v2/json/issues/comment/:user/:repo/{$issue->issue->number}",
false, stream_context_create(array(
"http" => array(
"method" => "POST",
'header' => sprintf("Authorization: Basic %s\r\n", base64_encode("(user):(pass)")).
"Content-type: application/x-www-form-urlencoded\r\n",
'content' => http_build_query(array("comment" => htmlentities($comment['comment_text']))),
)
))));
sleep(1);
}
sleep(1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment