} foreach ($res->fetchAll() as $row) { $label_name = $row['label_type'] . ': ' . $row['name']; if (array_key_exists($label_name, $remap_labels)) { $label_name = $remap_labels[$label_name]; } if (empty($label_name)) { $labels[$row['label_type']][crc32($row['name'])] = NULL; continue; } if (in_array($label_name, $existing_labels)) { echo "Label {$row['name']} already exists\n"; $labels[$row['label_type']][crc32($row['name'])] = $label_name; continue; } $resp = github_add_label(array('name' => $label_name, 'color' => $row['color'])); if (isset($resp['url'])) { // OK $labels[$row['label_type']][crc32($row['name'])] = $resp['name']; echo "Label {$row['name']} converted to {$resp['name']}\n"; } else { // Error $error = print_r($resp, 1); echo "Failed to convert label {$row['name']}: {$error}\n"; } } } // Try get previously fetched tickets $tickets = array(); if (file_exists($save_tickets)) { $tickets = unserialize(file_get_contents($save_tickets));
// Serialize to restore in future file_put_contents($save_milestones, serialize($milestones)); } $labels = array(); $labels['T'] = array(); $labels['C'] = array(); $labels['P'] = array(); $labels['R'] = array(); if (file_exists($save_labels)) { $labels = unserialize(file_get_contents($save_labels)); } if (!$skip_labels) { // Export all "labels" $res = $trac_db->query("SELECT DISTINCT 'T' label_type, type name, 'cccccc' color\n\t FROM ticket WHERE IFNULL(type, '') <> ''\n\t\t\t\t\t\t\tUNION\n\t\t\t\t\t\t\tSELECT DISTINCT 'C' label_type, component name, '0000aa' color\n\t FROM ticket WHERE IFNULL(component, '') <> ''\n\t\t\t\t\t\t\tUNION\n\t\t\t\t\t\t\tSELECT DISTINCT 'P' label_type, priority name, case when lower(priority) = 'urgent' then 'ff0000'\n\t\t\t\t\t\t\t when lower(priority) = 'high' then 'ff6666'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t when lower(priority) = 'medium' then 'ffaaaa'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t when lower(priority) = 'low' then 'ffdddd'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t else 'aa8888' end color\n\t FROM ticket WHERE IFNULL(priority, '') <> ''\n\t\t\t\t\t\t\tUNION\n\t\t\t\t\t\t\tSELECT DISTINCT 'R' label_type, resolution name, '55ff55' color\n\t FROM ticket WHERE IFNULL(resolution, '') <> ''"); foreach ($res->fetchAll() as $row) { $resp = github_add_label(array('name' => $row['label_type'] . ': ' . $row['name'], 'color' => $row['color'])); if (isset($resp['url'])) { // OK $labels[$row['label_type']][crc32($row['name'])] = $resp['name']; echo "Label {$row['name']} converted to {$resp['name']}\n"; } else { // Error $error = print_r($resp, 1); echo "Failed to convert label {$row['name']}: {$error}\n"; } } // Serialize to restore in future file_put_contents($save_labels, serialize($labels)); } // Try get previously fetched tickets $tickets = array();