Skip to content
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

Rename set-parent-branch to set-parent #2114

Merged
merged 3 commits into from Mar 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -49,8 +49,8 @@ Flow, and trunk-based development. Check out
branch as a child of the current branch
- [git prepend](https://www.git-town.com/commands/prepend.html) - insert a new
branch between the current branch and its parent
- [git set-parent-branch](https://www.git-town.com/commands/set-parent-branch.html) -
updates a branch's parent
- [git set-parent](https://www.git-town.com/commands/set-parent.html) - updates
a branch's parent

#### Setup/configuration

Expand Down
2 changes: 1 addition & 1 deletion features/help/help.feature
Expand Up @@ -29,7 +29,7 @@ Feature: help for commands
| prune-branches |
| rename-branch |
| repo |
| set-parent-branch |
| set-parent |
| ship |
| sync |
| version |
Expand Down
6 changes: 3 additions & 3 deletions features/set-parent-branch/set_parent_branch.feature
Expand Up @@ -7,13 +7,13 @@ Feature: update the parent of a feature branch
And the current branch is "child"

Scenario: select the default branch (current parent)
When I run "git-town set-parent-branch" and answer the prompts:
When I run "git-town set-parent" and answer the prompts:
| PROMPT | ANSWER |
| Please specify the parent branch of 'child' | [ENTER] |
And the initial branch hierarchy exists

Scenario: select another branch
When I run "git-town set-parent-branch" and answer the prompts:
When I run "git-town set-parent" and answer the prompts:
| PROMPT | ANSWER |
| Please specify the parent branch of 'child' | [UP][ENTER] |
Then this branch hierarchy exists now
Expand All @@ -22,7 +22,7 @@ Feature: update the parent of a feature branch
| parent | main |

Scenario: choose "<none> (make a perennial branch)"
When I run "git-town set-parent-branch" and answer the prompts:
When I run "git-town set-parent" and answer the prompts:
| PROMPT | ANSWER |
| Please specify the parent branch of 'child' | [UP][UP][ENTER] |
Then the perennial branches are now "child"
Expand Down
2 changes: 1 addition & 1 deletion features/shared/invalid_git_version.feature
Expand Up @@ -28,7 +28,7 @@ Feature: require minimum Git version
| pull-branch-strategy |
| rename-branch |
| repo |
| set-parent-branch |
| set-parent |
| ship |
| sync |
| version |
2 changes: 1 addition & 1 deletion features/shared/wrong_parameter_count.feature
Expand Up @@ -33,7 +33,7 @@ Feature: too few or many parameters
| rename-branch |
| rename-branch arg1 arg2 arg3 |
| repo arg1 |
| set-parent-branch arg1 |
| set-parent arg1 |
| ship arg1 arg2 |
| sync arg1 |
| version arg1 |
2 changes: 1 addition & 1 deletion src/cmd/append.go
Expand Up @@ -96,7 +96,7 @@ func appendStepList(config *appendConfig, repo *git.ProdRepo) (runstate.StepList
updateBranchSteps(&list, branch, true, repo)
}
list.Add(&steps.CreateBranchStep{Branch: config.targetBranch, StartingPoint: config.parentBranch})
list.Add(&steps.SetParentBranchStep{Branch: config.targetBranch, ParentBranch: config.parentBranch})
list.Add(&steps.SetParentStep{Branch: config.targetBranch, ParentBranch: config.parentBranch})
list.Add(&steps.CheckoutBranchStep{Branch: config.targetBranch})
if config.hasOrigin && config.shouldNewBranchPush && !config.isOffline {
list.Add(&steps.CreateTrackingBranchStep{Branch: config.targetBranch, NoPushHook: config.noPushHook})
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/kill.go
Expand Up @@ -151,7 +151,7 @@ func killStepList(config *killConfig, repo *git.ProdRepo) (runstate.StepList, er
}
result.Append(&steps.DeleteLocalBranchStep{Branch: config.targetBranch, Force: true})
for _, child := range config.childBranches {
result.Append(&steps.SetParentBranchStep{Branch: child, ParentBranch: config.targetBranchParent})
result.Append(&steps.SetParentStep{Branch: child, ParentBranch: config.targetBranchParent})
}
result.Append(&steps.DeleteParentBranchStep{Branch: config.targetBranch})
case !config.isOffline:
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/prepend.go
Expand Up @@ -113,8 +113,8 @@ func prependStepList(config *prependConfig, repo *git.ProdRepo) (runstate.StepLi
updateBranchSteps(&list, branch, true, repo)
}
list.Add(&steps.CreateBranchStep{Branch: config.targetBranch, StartingPoint: config.parentBranch})
list.Add(&steps.SetParentBranchStep{Branch: config.targetBranch, ParentBranch: config.parentBranch})
list.Add(&steps.SetParentBranchStep{Branch: config.initialBranch, ParentBranch: config.targetBranch})
list.Add(&steps.SetParentStep{Branch: config.targetBranch, ParentBranch: config.parentBranch})
list.Add(&steps.SetParentStep{Branch: config.initialBranch, ParentBranch: config.targetBranch})
list.Add(&steps.CheckoutBranchStep{Branch: config.targetBranch})
if config.hasOrigin && config.shouldNewBranchPush && !config.isOffline {
list.Add(&steps.CreateTrackingBranchStep{Branch: config.targetBranch, NoPushHook: config.noPushHook})
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/prune_branches.go
Expand Up @@ -85,7 +85,7 @@ func pruneBranchesStepList(config *pruneBranchesConfig, repo *git.ProdRepo) (run
parent := repo.Config.ParentBranch(branchWithDeletedRemote)
if parent != "" {
for _, child := range repo.Config.ChildBranches(branchWithDeletedRemote) {
result.Append(&steps.SetParentBranchStep{Branch: child, ParentBranch: parent})
result.Append(&steps.SetParentStep{Branch: child, ParentBranch: parent})
}
result.Append(&steps.DeleteParentBranchStep{Branch: branchWithDeletedRemote})
}
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/rename_branch.go
Expand Up @@ -158,10 +158,10 @@ func renameBranchStepList(config *renameBranchConfig, repo *git.ProdRepo) (runst
result.Append(&steps.AddToPerennialBranchesStep{Branch: config.newBranch})
} else {
result.Append(&steps.DeleteParentBranchStep{Branch: config.oldBranch})
result.Append(&steps.SetParentBranchStep{Branch: config.newBranch, ParentBranch: repo.Config.ParentBranch(config.oldBranch)})
result.Append(&steps.SetParentStep{Branch: config.newBranch, ParentBranch: repo.Config.ParentBranch(config.oldBranch)})
}
for _, child := range config.oldBranchChildren {
result.Append(&steps.SetParentBranchStep{Branch: child, ParentBranch: config.newBranch})
result.Append(&steps.SetParentStep{Branch: child, ParentBranch: config.newBranch})
}
if config.oldBranchHasTrackingBranch && !config.isOffline {
result.Append(&steps.CreateTrackingBranchStep{Branch: config.newBranch, NoPushHook: config.noPushHook})
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/root.go
Expand Up @@ -33,7 +33,7 @@ and it allows you to perform many common Git operations faster and easier.`,
rootCmd.AddCommand(pruneBranchesCommand(repo))
rootCmd.AddCommand(renameBranchCommand(repo))
rootCmd.AddCommand(repoCommand(repo))
rootCmd.AddCommand(setParentBranchCommand(repo))
rootCmd.AddCommand(setParentCommand(repo))
rootCmd.AddCommand(shipCmd(repo))
rootCmd.AddCommand(skipCmd(repo))
rootCmd.AddCommand(switchCmd(repo))
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/set_parent_branch.go → src/cmd/set_parent.go
Expand Up @@ -9,9 +9,9 @@ import (
"github.com/spf13/cobra"
)

func setParentBranchCommand(repo *git.ProdRepo) *cobra.Command {
func setParentCommand(repo *git.ProdRepo) *cobra.Command {
return &cobra.Command{
Use: "set-parent-branch",
Use: "set-parent",
Short: "Prompts to set the parent branch for the current branch",
Long: `Prompts to set the parent branch for the current branch`,
Run: func(cmd *cobra.Command, args []string) {
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/ship.go
Expand Up @@ -250,7 +250,7 @@ func shipStepList(config *shipConfig, commitMessage string, repo *git.ProdRepo)
list.Add(&steps.DeleteLocalBranchStep{Branch: config.branchToShip})
list.Add(&steps.DeleteParentBranchStep{Branch: config.branchToShip})
for _, child := range config.childBranches {
list.Add(&steps.SetParentBranchStep{Branch: child, ParentBranch: config.branchToMergeInto})
list.Add(&steps.SetParentStep{Branch: child, ParentBranch: config.branchToMergeInto})
}
if !config.isShippingInitialBranch {
// TODO: check out the main branch here?
Expand Down
4 changes: 2 additions & 2 deletions src/config/core.go
Expand Up @@ -373,9 +373,9 @@ func (gt *GitTown) SetOffline(value bool) error {
return err
}

// SetParentBranch marks the given branch as the direct parent of the other given branch
// SetParent marks the given branch as the direct parent of the other given branch
// in the Git Town configuration.
func (gt *GitTown) SetParentBranch(branch, parentBranch string) error {
func (gt *GitTown) SetParent(branch, parentBranch string) error {
_, err := gt.Storage.SetLocalConfigValue("git-town-branch."+branch+".parent", parentBranch)
return err
}
Expand Down
2 changes: 1 addition & 1 deletion src/dialog/parent_branches.go
Expand Up @@ -49,7 +49,7 @@ func (pbd *ParentBranches) AskForBranchAncestry(branch, defaultBranch string, re
}
break
}
err = repo.Config.SetParentBranch(current, parent)
err = repo.Config.SetParent(current, parent)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion src/git/runner.go
Expand Up @@ -240,7 +240,7 @@ func (r *Runner) CreateChildFeatureBranch(name string, parent string) error {
if err != nil {
return fmt.Errorf("cannot create child branch %q: %w", name, err)
}
_ = r.Config.SetParentBranch(name, parent)
_ = r.Config.SetParent(name, parent)
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions src/runstate/jsonstep.go
Expand Up @@ -97,8 +97,8 @@ func determineStep(stepType string) steps.Step {
return &steps.RestoreOpenChangesStep{}
case "*RevertCommitStep":
return &steps.RevertCommitStep{}
case "*SetParentBranchStep":
return &steps.SetParentBranchStep{}
case "*SetParentStep":
return &steps.SetParentStep{}
case "*SquashMergeBranchStep":
return &steps.SquashMergeBranchStep{}
case "*SkipCurrentBranchSteps":
Expand Down
2 changes: 1 addition & 1 deletion src/steps/delete_parent_branch_step.go
Expand Up @@ -16,7 +16,7 @@ func (step *DeleteParentBranchStep) CreateUndoStep(repo *git.ProdRepo) (Step, er
if step.previousParent == "" {
return &NoOpStep{}, nil
}
return &SetParentBranchStep{Branch: step.Branch, ParentBranch: step.previousParent}, nil
return &SetParentStep{Branch: step.Branch, ParentBranch: step.previousParent}, nil
}

func (step *DeleteParentBranchStep) Run(repo *git.ProdRepo, connector hosting.Connector) error {
Expand Down
12 changes: 6 additions & 6 deletions src/steps/set_parent_branch_step.go
Expand Up @@ -5,23 +5,23 @@ import (
"github.com/git-town/git-town/v7/src/hosting"
)

// SetParentBranchStep registers the branch with the given name as a parent
// SetParentStep registers the branch with the given name as a parent
// of the branch with the other given name.
type SetParentBranchStep struct {
type SetParentStep struct {
NoOpStep
Branch string
ParentBranch string
previousParent string
}

func (step *SetParentBranchStep) CreateUndoStep(repo *git.ProdRepo) (Step, error) {
func (step *SetParentStep) CreateUndoStep(repo *git.ProdRepo) (Step, error) {
if step.previousParent == "" {
return &DeleteParentBranchStep{Branch: step.Branch}, nil
}
return &SetParentBranchStep{Branch: step.Branch, ParentBranch: step.previousParent}, nil
return &SetParentStep{Branch: step.Branch, ParentBranch: step.previousParent}, nil
}

func (step *SetParentBranchStep) Run(repo *git.ProdRepo, connector hosting.Connector) error {
func (step *SetParentStep) Run(repo *git.ProdRepo, connector hosting.Connector) error {
step.previousParent = repo.Config.ParentBranch(step.Branch)
return repo.Config.SetParentBranch(step.Branch, step.ParentBranch)
return repo.Config.SetParent(step.Branch, step.ParentBranch)
}
2 changes: 1 addition & 1 deletion test/steps.go
Expand Up @@ -619,7 +619,7 @@ func Steps(suite *godog.Suite, state *ScenarioState) {
})

suite.Step(`^the coworker sets the parent branch of "([^"]*)" as "([^"]*)"$`, func(childBranch, parentBranch string) error {
_ = state.gitEnv.CoworkerRepo.Config.SetParentBranch(childBranch, parentBranch)
_ = state.gitEnv.CoworkerRepo.Config.SetParent(childBranch, parentBranch)
return nil
})

Expand Down
2 changes: 1 addition & 1 deletion website/src/SUMMARY.md
Expand Up @@ -19,7 +19,7 @@
- [Nested feature branches](nested-feature-branches.md)
- [append](commands/append.md)
- [prepend](commands/prepend.md)
- [set-parent-branch](commands/set-parent-branch.md)
- [set-parent](commands/set-parent.md)
- [Installation commands](installation-commands.md)
- [aliases](commands/install-aliases.md)
- [completions](commands/install-completions.md)
Expand Down
4 changes: 2 additions & 2 deletions website/src/all-commands.md
Expand Up @@ -28,8 +28,8 @@ commands in the shorter form available after running
the current branch
- [git prepend](commands/prepend.md) - create a new feature branch between the
current branch and its parent
- [git town set-parent-branch](commands/set-parent-branch.md) - change the
parent of a feature branch
- [git town set-parent](commands/set-parent.md) - change the parent of a feature
branch

### Git Town installation

Expand Down
6 changes: 0 additions & 6 deletions website/src/commands/set-parent-branch.md

This file was deleted.

6 changes: 6 additions & 0 deletions website/src/commands/set-parent.md
@@ -0,0 +1,6 @@
# git set-parent

The _set-parent_ command changes the parent branch for the current branch. It
prompts the user for the new parent branch. Ideally you run [git sync](sync.md)
when done updating parent branches to resolve merge conflicts between this
branch and its new parent.
3 changes: 1 addition & 2 deletions website/src/nested-feature-branches.md
Expand Up @@ -200,5 +200,4 @@ ship them in any order.
_Organize branch chains in the order you want to ship:_ You always have to ship
the oldest branch first. You can use [git prepend](commands/prepend.md) to
insert a feature branch as a parent of the current feature branch or
[set parent branch](commands/set-parent-branch.md) to change the order of
branches.
[set parent](commands/set-parent.md) to change the order of branches.