Make version optional, remove Premium-related code [MAILPOET-1783]
This commit is contained in:
38
RoboFile.php
38
RoboFile.php
@ -553,9 +553,6 @@ class RoboFile extends \Robo\Tasks {
|
||||
function changelogUpdate($opts = ['version-name' => null]) {
|
||||
$this->say("Updating changelog");
|
||||
$outputs = $this->getChangelogController()->update($opts['version-name']);
|
||||
if ($opts['quiet']) {
|
||||
return;
|
||||
}
|
||||
$this->say("Changelog \n{$outputs[0]} \n{$outputs[1]}\n\n");
|
||||
$this->say("IMPORTANT NOTES \n" . ($outputs[2] ?: 'none'));
|
||||
}
|
||||
@ -588,13 +585,13 @@ class RoboFile extends \Robo\Tasks {
|
||||
);
|
||||
}
|
||||
|
||||
protected function getReleaseVersionController($project) {
|
||||
protected function getReleaseVersionController() {
|
||||
require_once './tasks/release/ReleaseVersionController.php';
|
||||
$this->loadEnv();
|
||||
return \MailPoetTasks\Release\ReleaseVersionController::createWithJiraCredentials(
|
||||
getenv('WP_JIRA_TOKEN'),
|
||||
getenv('WP_JIRA_USER'),
|
||||
$project
|
||||
\MailPoetTasks\Release\Jira::PROJECT_MAILPOET
|
||||
);
|
||||
}
|
||||
|
||||
@ -626,30 +623,21 @@ class RoboFile extends \Robo\Tasks {
|
||||
->run();
|
||||
}
|
||||
|
||||
public function jiraReleaseVersion($opts = ['free' => null, 'premium' => null]) {
|
||||
require_once './tasks/release/Jira.php';
|
||||
if (empty($opts['free']) && empty($opts['premium'])) {
|
||||
$this->yell('No Free or Premium version specified', 40, 'red');
|
||||
public function jiraReleaseVersion($version = null, $opts = []) {
|
||||
if ($version) {
|
||||
$this->validateVersion($version);
|
||||
}
|
||||
try {
|
||||
$output = $this->getReleaseVersionController()
|
||||
->assignVersionToCompletedTickets($version);
|
||||
} catch (\Exception $e) {
|
||||
$this->yell($e->getMessage(), 40, 'red');
|
||||
exit(1);
|
||||
}
|
||||
$output = [];
|
||||
if (!empty($opts['free'])) {
|
||||
$this->validateVersion($opts['free']);
|
||||
$output[] = $this->getReleaseVersionController(\MailPoetTasks\Release\Jira::PROJECT_MAILPOET)
|
||||
->assignVersionToCompletedTickets($opts['free']);
|
||||
}
|
||||
if (!empty($opts['premium'])) {
|
||||
$this->validateVersion($opts['premium']);
|
||||
$output[] = $this->getReleaseVersionController(\MailPoetTasks\Release\Jira::PROJECT_PREMIUM)
|
||||
->assignVersionToCompletedTickets($opts['premium']);
|
||||
}
|
||||
if($opts['quiet']) {
|
||||
return;
|
||||
}
|
||||
$this->say(join("\n", $output));
|
||||
$this->say($output);
|
||||
}
|
||||
|
||||
private function validateVersion($version) {
|
||||
protected function validateVersion($version) {
|
||||
if (!preg_match('/\d+\.\d+\.\d+/', $version)) {
|
||||
$this->yell('Incorrect version format', 40, 'red');
|
||||
exit(1);
|
||||
|
@ -21,15 +21,13 @@ class ReleaseVersionController {
|
||||
return new self(new Jira($token, $user, $project), $project);
|
||||
}
|
||||
|
||||
function assignVersionToCompletedTickets($version) {
|
||||
$output = [];
|
||||
$output[] = "Checking version $version in $this->project";
|
||||
|
||||
if (!$this->checkVersion($version)) {
|
||||
$output[] = "The version is invalid or already released";
|
||||
return join("\n", $output);
|
||||
function assignVersionToCompletedTickets($version = null) {
|
||||
$version = $this->checkVersion($version);
|
||||
if (!$version) {
|
||||
throw new \Exception('The version is invalid or already released');
|
||||
}
|
||||
|
||||
$output = [];
|
||||
$output[] = "Setting version $version to completed tickets in $this->project...";
|
||||
$issues = $this->getDoneIssuesWithoutVersion();
|
||||
$result = array_map(function ($issue) use ($version) {
|
||||
@ -40,7 +38,7 @@ class ReleaseVersionController {
|
||||
return join("\n", $output);
|
||||
}
|
||||
|
||||
function getDoneIssuesWithoutVersion() {
|
||||
private function getDoneIssuesWithoutVersion() {
|
||||
$jql = "project = $this->project AND status = Done AND (fixVersion = EMPTY OR fixVersion IN unreleasedVersions()) AND updated >= -52w";
|
||||
$result = $this->jira->search($jql, ['key']);
|
||||
return array_map(function ($issue) {
|
||||
@ -51,7 +49,7 @@ class ReleaseVersionController {
|
||||
}, $result['issues']);
|
||||
}
|
||||
|
||||
function checkVersion($version) {
|
||||
private function checkVersion($version) {
|
||||
try {
|
||||
$version_data = $this->jira->getVersion($version);
|
||||
} catch (\Exception $e) {
|
||||
@ -63,12 +61,13 @@ class ReleaseVersionController {
|
||||
} else if (empty($version_data)) {
|
||||
// version does not exist
|
||||
$this->jira->createVersion($version);
|
||||
return $version;
|
||||
}
|
||||
// version exists
|
||||
return true;
|
||||
return $version_data['name'];
|
||||
}
|
||||
|
||||
function setIssueFixVersion($issue_key, $version) {
|
||||
private function setIssueFixVersion($issue_key, $version) {
|
||||
$data = [
|
||||
'update' => [
|
||||
'fixVersions' => [
|
||||
|
Reference in New Issue
Block a user