-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rollback ! #103
base: main
Are you sure you want to change the base?
Rollback ! #103
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the project RMT | ||
* | ||
* Copyright (c) 2013, Liip AG, http://www.liip.ch | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Liip\RMT\Command; | ||
|
||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Liip\RMT\Context; | ||
|
||
/** | ||
* Rollback the last release | ||
*/ | ||
class RollbackCommand extends BaseCommand | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function configure() | ||
{ | ||
$this->setName('rollback'); | ||
$this->setDescription('Rollback the last release if there was no change since.'); | ||
$this->setHelp('The <comment>rollback</comment> should be used to cancel a previously done release.'); | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
if (count(Context::get('vcs')->getLocalModifications()) > 0) { | ||
Context::get('output')->writeln('<error>Local modifications found. Aborting.</error>'); | ||
return; | ||
} | ||
|
||
$tag = Context::get('version-persister')->getCurrentVersionTag(); | ||
$modifications = Context::get('vcs')->getAllModificationsSince($tag, false, false); | ||
if (count($modifications) > 0) { | ||
Context::get('output')->writeln('<error>There were commits since the last release. Aborting.</error>'); | ||
return; | ||
} | ||
|
||
$this->rollbackActionListIfExist('post-release-actions'); | ||
$this->rollbackActionListIfExist('pre-release-actions'); | ||
} | ||
|
||
protected function rollbackActionListIfExist($name) | ||
{ | ||
$actions = Context::getInstance()->getList($name); | ||
$actions = array_reverse($actions); | ||
foreach ($actions as $num => $action) { | ||
$this->getOutput()->write(++$num.') '.$action->getTitle().' : '); | ||
$action->rollback(); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,13 @@ public function getTags(); | |
*/ | ||
public function createTag($tagName); | ||
|
||
/** | ||
* Delete a tag | ||
* | ||
* @param string $tagName | ||
*/ | ||
public function deleteTag($tagName); | ||
|
||
/** | ||
* Publish a new created tag | ||
* | ||
|
@@ -78,6 +85,14 @@ public function getLocalModifications(); | |
*/ | ||
public function saveWorkingCopy($commitMsg = ''); | ||
|
||
/** | ||
* Revert the last commit. If a message is given, only revert | ||
* if the commit message matches. | ||
* | ||
* @param string|null $commitMsg | ||
*/ | ||
public function revertLastCommit($commitMsg = null); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't like that the revertLastCommit is based on the commit message. Since some months I'm thinking about writing more explicit commit message. Currently we have: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, if we start to use user input this could be an error. But I was not confident enough to just delete the last commit without any check. Can we guarantee that a commit will be done each time ? |
||
|
||
/** | ||
* Publish local modification | ||
* | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing
$this->rollbackReleaseAction
in the middle, no?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does the release action do that has to be rollbacked ?
Or asked with other words, what won't be rollbacked by the fact that we undo the last commit ?