diff --git a/features/rename_branch/features/local_branch.feature b/features/rename_branch/features/local_branch.feature new file mode 100644 index 0000000000..4d8cc852d5 --- /dev/null +++ b/features/rename_branch/features/local_branch.feature @@ -0,0 +1,32 @@ +Feature: rename a local-only branch + + Background: + Given the current branch is a local feature branch "old" + And the commits + | BRANCH | LOCATION | MESSAGE | + | main | local, origin | main commit | + | old | local | old commit | + When I run "git-town rename-branch new" + + Scenario: result + Then it runs the commands + | BRANCH | COMMAND | + | old | git fetch --prune --tags | + | | git branch new old | + | | git checkout new | + | new | git branch -D old | + And the current branch is now "new" + And now these commits exist + | BRANCH | LOCATION | MESSAGE | + | main | local, origin | main commit | + | new | local | old commit | + + Scenario: undo + When I run "git-town undo" + Then it runs the commands + | BRANCH | COMMAND | + | new | git branch old {{ sha 'old commit' }} | + | | git checkout old | + | old | git branch -D new | + And the current branch is now "old" + And the initial branches and hierarchy exist diff --git a/src/cmd/rename_branch.go b/src/cmd/rename_branch.go index d904b312f2..9f6c91ecc2 100644 --- a/src/cmd/rename_branch.go +++ b/src/cmd/rename_branch.go @@ -143,7 +143,7 @@ func determineRenameBranchConfig(args []string, forceFlag bool, repo *execute.Op if oldBranch == nil { return nil, branchesSnapshot, stashSnapshot, false, fmt.Errorf(messages.BranchDoesntExist, oldBranchName) } - if oldBranch.SyncStatus != domain.SyncStatusUpToDate { + if oldBranch.SyncStatus != domain.SyncStatusUpToDate && oldBranch.SyncStatus != domain.SyncStatusLocalOnly { return nil, branchesSnapshot, stashSnapshot, false, fmt.Errorf(messages.RenameBranchNotInSync, oldBranchName) } if branches.All.HasLocalBranch(newBranchName) {