-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add 'git-planbox releasable' command.
- Loading branch information
Showing
5 changed files
with
131 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
/** | ||
* git pb releasable [iteration] | ||
* | ||
* List stories that are completed, delivered, or accepted | ||
* but not yet released. | ||
*/ | ||
class GitPlanbox_Releasable extends CLIMax_BaseCommand | ||
{ | ||
|
||
public function run($arguments, CLImaxController $cliController) | ||
{ | ||
// Set up options for search | ||
$config = GitPlanbox_Config::get(); | ||
$statuses = array('completed', 'delivered', 'accepted'); | ||
$opts = array( | ||
'productid' => $config->productid(), | ||
'timeframe' => $timeframe, | ||
'status' => $statuses, | ||
); | ||
|
||
// Pull in timeframe(s) if they've been specified | ||
if (isset($arguments[0])) | ||
{ | ||
$opts['timeframe'] = explode(',', $arguments[0]); | ||
} else { | ||
$opts['timeframe'] = array('last', 'current', 'next'); | ||
} | ||
|
||
// Create a session so we can run commands | ||
$session = GitPlanbox_Session::create(); | ||
|
||
// Get a list of stories | ||
$stories = GitPlanbox_Search::search($session, $opts); | ||
|
||
if (count($stories) == 0) | ||
{ | ||
print("There are no stories in status: " . implode(', ', $statuses) . ".\n"); | ||
return 0; | ||
} | ||
|
||
// Format stories nicely | ||
print("Stories that are ready for release:\n"); | ||
foreach ($stories as $story) | ||
{ | ||
printf("%8s %10s - %-50s\n", "#{$story->id}", $story->status, $story->name); | ||
} | ||
print("\nHint: use `git-planbox status <storyId>` to find out what branch the story is on.\n\n"); | ||
|
||
return 0; | ||
} | ||
|
||
public function getDescription($aliases, $argLinker) | ||
{ | ||
return 'List planbox stories that are ready for release.'; | ||
} | ||
|
||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
class GitPlanbox_Search | ||
{ | ||
|
||
/** | ||
* Find planbox stories matching a set of criteria. | ||
* | ||
* @param array $opts Options for restricting the search: | ||
* - productid: (int) The planbox product id (project identifier) | ||
* - timeframe: (mixed) String or array of timeframes, e.g. array('current', 'next', 'backlog') or 'current' | ||
* - resourceid: (mixed) Int or array of resourceids of planbox users involved in stories | ||
* - status: (mixed) String or array of statuses to include, e.g. array('completed', 'delivered') or 'completed' | ||
*/ | ||
public static function search($session, $opts = array()) | ||
{ | ||
if (!$session) throw new Exception("Invalid GitPlanbox_Session."); | ||
|
||
$postData = array(); | ||
|
||
// Restrict by product id | ||
if (isset($opts['productid'])) $postData['product_id'] = $opts['productid']; | ||
|
||
// Restrict by timeframe(s), default=current | ||
if (isset($opts['timeframe'])) | ||
{ | ||
$postData['timeframe'] = $opts['timeframe']; | ||
} else { | ||
$postData['timeframe'] = 'current'; | ||
} | ||
|
||
// Restrict by user (i.e. the git-planbox user) | ||
if (isset($opts['resourceid'])) $postData['resource_id'] = $opts['resourceid']; | ||
|
||
// Get the list of stories | ||
$stories = $session->post('get_stories', $postData); | ||
|
||
// Restrict by story status(es) | ||
if (!isset($opts['status'])) return $stories; | ||
$statuses = $opts['status']; | ||
if (!is_array($opts['status'])) $statuses = array($statuses); | ||
$retVal = array(); | ||
foreach ($stories as $story) | ||
{ | ||
// Skip stories with statuses we don't care about | ||
if (!in_array($story->status, $statuses)) continue; | ||
array_push($retVal, $story); | ||
} | ||
|
||
// Return the list | ||
return $retVal; | ||
} | ||
|
||
} | ||
|