def __delete_branch(doomed_name, force = False):
doomed = stack.Series(doomed_name)
+ if __is_current_branch(doomed_name):
+ raise CmdException('Cannot delete the current branch')
if doomed.get_protected():
raise CmdException, 'This branch is protected. Delete is not permitted'
out.start('Deleting branch "%s"' % doomed_name)
-
- if __is_current_branch(doomed_name):
- raise CmdException('Cannot delete the current branch')
-
doomed.delete(force)
-
out.done()
def func(parser, options, args):
raise StackException('Series directory %s is not empty'
% self._dir())
- try:
- git.delete_branch(self.get_name())
- except GitException:
- out.warn('Could not delete branch "%s"' % self.get_name())
+ try:
+ git.delete_branch(self.get_name())
+ except GitException:
+ out.warn('Could not delete branch "%s"' % self.get_name())
config.remove_section('branch.%s' % self.get_name())
config.remove_section('branch.%s.stgit' % self.get_name())
. ./test-lib.sh
-stg init
+test_expect_success \
+ 'Create a branch when the current one is not an StGIT stack' '
+ git branch origin &&
+ stg branch --create new origin &&
+ test $(stg branch) == "new"
+'
test_expect_success \
'Create a spurious patches/ entry' '
+ stg branch master &&
+ stg init &&
find .git -name foo | xargs rm -rf &&
mkdir -p .git/patches && touch .git/patches/foo
'
stg branch --delete master
'
+test_expect_success 'Create a non-StGIT branch and delete it' '
+ git branch bar &&
+ stg branch --delete bar
+ '
+
test_expect_success 'Make sure the branch ref was deleted' '
[ -z "$(git show-ref | grep master | tee /dev/stderr)" ]
'