Last active
April 15, 2019 15:43
-
-
Save polo2ro/9b004ecf9baeafbae3edb30538875b23 to your computer and use it in GitHub Desktop.
bitbucket issues generator from CSV
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 | |
$issues = []; | |
if (($handle = fopen("tickets.csv", "r")) !== FALSE) { | |
$header = fgetcsv($handle); | |
while (($data = fgetcsv($handle)) !== FALSE) { | |
$row = array_combine($header, $data); | |
$content = $row['description']; | |
if ($row['echanges']) { | |
$content .= "\n\n échanges:\n".$row['echanges']; | |
} | |
$created_on = str_replace(' ', 'T', $row['dateticket']); | |
$issues[] = [ | |
"status" => 2 === (int) $row['Evaluation'] ? "new" : "open", | |
"priority" => "major", | |
"kind" => "bug", | |
"content_updated_on" => null, | |
"voters" => [], | |
"title" => $row['titre'], | |
"reporter" => [ | |
"display_name" => "Paul de Rosanbo", | |
"account_id" => "557058:c53221b1-312c-4b51-b2db-a43a0385fb04" | |
], | |
"component" => null, | |
"watchers" => [ | |
[ | |
"display_name" => "Paul de Rosanbo", | |
"account_id" => "557058:c53221b1-312c-4b51-b2db-a43a0385fb04" | |
] | |
], | |
"content" => $content, | |
"assignee" => [ | |
"display_name" => "Paul de Rosanbo", | |
"account_id" => "557058:c53221b1-312c-4b51-b2db-a43a0385fb04" | |
], | |
"created_on" => $created_on.".000000+00:00", | |
"version" => null, | |
"edited_on" => null, | |
"milestone" => null, | |
"updated_on" => "2019-04-15T12:21:17.636133+00:00", | |
"id" => (int) substr($row['reference'], 1) | |
]; | |
} | |
fclose($handle); | |
} | |
echo json_encode([ | |
"milestones" => [], | |
"attachments" => [], | |
"versions" => [], | |
"comments" => [], | |
"meta" => [ | |
"default_milestone" => null, | |
"default_assignee" => null, | |
"default_kind" => "bug", | |
"default_component" => null, | |
"default_version" => null | |
], | |
"components" => [], | |
"issues" => $issues, | |
"logs" => [] | |
], JSON_PRETTY_PRINT); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment