From ac56fbfd4b0b1fe98faea07eceb3fcb138dd5699 Mon Sep 17 00:00:00 2001 From: Daniel Wehner Date: Fri, 16 Jan 2015 17:42:35 +0100 Subject: [PATCH] make it possible to add a tag on an existing issue --- dop | 2 + src/DrupalPatchUtils/Command/TagIssue.php | 54 +++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 src/DrupalPatchUtils/Command/TagIssue.php diff --git a/dop b/dop index 599c0ec..dfa08b8 100755 --- a/dop +++ b/dop @@ -10,6 +10,7 @@ use DrupalPatchUtils\Command\Logout; use DrupalPatchUtils\Command\PostComment; use DrupalPatchUtils\Command\SearchIssuePatch; use DrupalPatchUtils\Command\SearchRtbcPatches; +use DrupalPatchUtils\Command\TagIssue; use DrupalPatchUtils\Command\ValidatePatch; use DrupalPatchUtils\Command\ValidateRtbcPatches; use Symfony\Component\Console\Application; @@ -23,6 +24,7 @@ $application->add(new SearchIssuePatch()); $application->add(new SearchRtbcPatches()); $application->add(new ValidatePatch()); $application->add(new ValidateRtbcPatches()); +$application->add(new TagIssue()); $application->add(new Login()); $application->add(new Logout()); $application->run(); diff --git a/src/DrupalPatchUtils/Command/TagIssue.php b/src/DrupalPatchUtils/Command/TagIssue.php new file mode 100644 index 0000000..35cf02e --- /dev/null +++ b/src/DrupalPatchUtils/Command/TagIssue.php @@ -0,0 +1,54 @@ +setName('tagIssue') + ->setAliases(array('ti')) + ->setDescription('Add a tag to an existing issue') + ->addArgument( + 'url', + InputArgument::REQUIRED, + 'What is the url of the issue to retrieve?' + ) + ->addArgument( + 'tag', + InputArgument::REQUIRED, + 'The new tag' + ); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $issue = $this->getIssue($input->getArgument('url')); + + $browser = new DoBrowser(); + if (!$browser->loggedIn()) { + $browser->login($this->getConfig()->getDrupalUser(), $this->ask($output, "Enter your Drupal.org password: ", '', TRUE)); + } + + $comment_form = $browser->getCommentForm($issue->getUri()); + + $comment_form->setCommentText('Add tag'); + $comment_form->ensureTag($input->getArgument('tag')); + + $browser->submitForm($comment_form->getForm()); + $output->writeln('Added tag'); + } + +}