Page MenuHomePhabricator
Paste P1828

Generate dot graph of ticket dependencies for a project
ActivePublic

Authored by altendky on Jul 17 2015, 8:23 PM.
#!/usr/bin/env php
<?php
require '/path/to/libphutil/src/__phutil_library_init__.php';
# TODO customize or parameterize or... these
$uri = 'fill_me_in';
$certificate = 'fill_me_in';
$username = 'fill_me_in';
$client = new ConduitClient($uri);
$args = new PhutilArgumentParser($argv);
$args->parse(
array(
array(
'name' => 'project',
'param' => 'projname',
'short' => 'p',
'help' => 'The project name to process.',
),
));
$project_name = $args->getArg('project');
$params = array(
'certificate' => $certificate,
'client' => 'mytestclient',
'clientVersion' => '1.0',
'user' => $username,
'host' => $uri
);
$client->callMethodSynchronous('conduit.connect', $params);
$projects = $client->callMethodSynchronous('project.query', array('names' => [$project_name]));
$project_phid = array_keys($projects['data'])[0];
$tasks = $client->callMethodSynchronous('maniphest.query', array('projectPHIDs' => [$project_phid]));
print('dot {{{' . PHP_EOL);
print(' digraph {' . PHP_EOL);
foreach ($tasks as $task) {
# print('T' . $task['id'] . ': ' . $task['title'] . PHP_EOL);
print(str_replace('-', '_', $task['phid']) . ' [label="T' . $task['id'] . '" URL="' . $uri . 'T' . $task['id'] . '"]' . PHP_EOL);
foreach ($task['dependsOnTaskPHIDs'] as $dependsOnPhid) {
# print(' ' . $dependsOnPhid . PHP_EOL);
print(str_replace('-', '_', $dependsOnPhid) . ' -> ' . str_replace('-', '_', $task['phid']) . PHP_EOL);
}
}
print(' }' . PHP_EOL);
print('}}}' . PHP_EOL);
?>

Event Timeline

altendky changed the title of this paste from untitled to Generate dot graph of ticket dependencies for a project.
altendky updated the paste's language from autodetect to php.