From 3f665e8bbbf6d4dec9e2eb1d59724c519bbdbda8 Mon Sep 17 00:00:00 2001 From: till Date: Thu, 8 Mar 2012 15:44:29 +0100 Subject: [PATCH] * method to gather if this session is 'interactive' or 'non interactive' --- src/Composer/Repository/Vcs/SvnDriver.php | 22 +++++++++++++++++++ .../Test/Repository/Vcs/SvnDriverTest.php | 6 +++++ 2 files changed, 28 insertions(+) diff --git a/src/Composer/Repository/Vcs/SvnDriver.php b/src/Composer/Repository/Vcs/SvnDriver.php index c72a85b9d..bccd1e000 100644 --- a/src/Composer/Repository/Vcs/SvnDriver.php +++ b/src/Composer/Repository/Vcs/SvnDriver.php @@ -242,6 +242,28 @@ class SvnDriver extends VcsDriver implements VcsDriverInterface ); } + /** + * Determine if composer was called with --no-interaction/-n + * and return the option string for the command. + * + * @return string + * @uses parent::$io + * @see IOInterface::isInteractive() + */ + public function getSvnInteractiveSetting() + { + static $option; + if ($option !== null) { + return $option; + } + if ($this->io->isInteractive() === false) { + $option = '--non-interactive '; + } else { + $option = ''; + } + return $option; + } + /** * {@inheritDoc} */ diff --git a/tests/Composer/Test/Repository/Vcs/SvnDriverTest.php b/tests/Composer/Test/Repository/Vcs/SvnDriverTest.php index 7d4578930..12e931eef 100644 --- a/tests/Composer/Test/Repository/Vcs/SvnDriverTest.php +++ b/tests/Composer/Test/Repository/Vcs/SvnDriverTest.php @@ -44,4 +44,10 @@ class SvnDriverTest extends \PHPUnit_Framework_TestCase $this->assertEquals($expect, $svn->getSvnCredentialString()); } + + public function testInteractiveString() + { + $io = new \Composer\IO\NullIO; // non-interactive by design + $svn = new SvnDriver('http://svn.example.org', $io); + } }