From 15a85247c26bd6828aceb684afd3457c046387e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zsolt=20G=C3=A1l?= Date: Thu, 15 Dec 2016 12:03:32 +0100 Subject: [PATCH] Add move option, fixes --- src/Technodelight/Jira/Api/Api.php | 2 +- src/Technodelight/Jira/Api/Worklog.php | 2 +- .../Jira/Console/Command/LogTimeCommand.php | 14 ++++++++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Technodelight/Jira/Api/Api.php b/src/Technodelight/Jira/Api/Api.php index cfb02c6..ac72427 100644 --- a/src/Technodelight/Jira/Api/Api.php +++ b/src/Technodelight/Jira/Api/Api.php @@ -80,7 +80,7 @@ public function worklog($issueKey, $timeSpent, $comment, $started, $adjustEstima sprintf('issue/%s/worklog', $issueKey) . '?' . http_build_query($params), [ 'comment' => $comment, - 'started' => $started, + 'started' => DateHelper::dateTimeToJira($started), 'timeSpent' => $timeSpent, ] ); diff --git a/src/Technodelight/Jira/Api/Worklog.php b/src/Technodelight/Jira/Api/Worklog.php index 4a759d9..4d6d12b 100644 --- a/src/Technodelight/Jira/Api/Worklog.php +++ b/src/Technodelight/Jira/Api/Worklog.php @@ -31,7 +31,7 @@ public static function fromArray(array $record, $issueKey) $record['id'], $record['author']['displayName'], isset($record['comment']) ? $record['comment'] : null, - DateHelper::dateTimeFromJira($record['started'])->format('Y-m-d'), + DateHelper::dateTimeFromJira($record['started'])->format('Y-m-d H:i:s'), $record['timeSpent'], $record['timeSpentSeconds'] ); diff --git a/src/Technodelight/Jira/Console/Command/LogTimeCommand.php b/src/Technodelight/Jira/Console/Command/LogTimeCommand.php index 970c690..ffeee08 100644 --- a/src/Technodelight/Jira/Console/Command/LogTimeCommand.php +++ b/src/Technodelight/Jira/Console/Command/LogTimeCommand.php @@ -45,6 +45,12 @@ protected function configure() InputOption::VALUE_NONE, 'Delete worklog' ) + ->addOption( + 'move', + 'm', + InputOption::VALUE_REQUIRED, + 'Move worklog to another date' + ) ; } @@ -68,7 +74,7 @@ protected function interact(InputInterface $input, OutputInterface $output) $input->setArgument('issueKey', $issueKey); } - if ($input->getOption('delete')) { + if ($input->getOption('delete') || $input->getOption('move')) { return; } @@ -120,7 +126,7 @@ function ($answer) { false ); - $input->setArgument('comment', $comment); + $input->setArgument('comment', $comment ?: $defaultMessage); } } @@ -132,7 +138,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $issueKey = $this->issueKeyArgument($input); $timeSpent = $input->getArgument('time') ?: null; $comment = $input->getArgument('comment') ?: null; - $startDay = $input->getArgument('date') ?: null; + $startDay = $input->getArgument('date') ?: $input->getOption('move'); if (intval($issueKey)) { try { @@ -205,7 +211,7 @@ private function logNewWork($issueKey, $timeSpent, $comment, $startDay) $issueKey, $timeSpent, $comment ?: sprintf('Worked on issue %s', $issueKey), - DateHelper::dateTimeToJira($startDay ?: 'today') + $startDay ?: 'today' ); $issue = $jira->retrieveIssue($issueKey);