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

switch displays incorrect if set-parent was previous used on perennial branch #3218

Closed
tranhl opened this issue Mar 21, 2024 · 4 comments · Fixed by #3223
Closed

switch displays incorrect if set-parent was previous used on perennial branch #3218

tranhl opened this issue Mar 21, 2024 · 4 comments · Fixed by #3223
Labels

Comments

@tranhl
Copy link

tranhl commented Mar 21, 2024

Let's say I have a branch called release-v1.0.0. Logically speaking it is a perennial branch, but for whatever reason it was not set as a perennial either via perennial-branches or perennial-regex. If I set its parent to main, then Git Town will keep track of it as a feature branch by adding the following to the local Git config file:

[git-town-branch "release-v1.0.0"]
	parent = main

So according to Git Town, release-v1.0.0 is considered a feature branch. Now if set perennial-regex to release-.* and run gt switch, I will see this:

* main
>   release-v1.0.0


  ↑/k up   ↓/j down   ←/u 10 up   →/d 10 down   enter/o accept   q/esc/ctrl-c abort

However, this is technically not correct, as release-v1.0.0 is perennial and technically shouldn't have a parent anymore. I expect switch to show me this instead:

* main
> release-v1.0.0


  ↑/k up   ↓/j down   ←/u 10 up   →/d 10 down   enter/o accept   q/esc/ctrl-c abort

Which correctly indicates that release-v1.0.0 is perennial. As part of the switch command, perhaps we could clean up branch config from the local Git config file to correctly?

I believe this would be need to be addressed in order to complete #3164 as well, since in case where this happens, what would Git Town consider the branch type for release-v1.0.0 to be?

@tranhl tranhl changed the title switch shows incorrect lineage if set-parent was previous used on perennial branch switch displays incorrect if set-parent was previous used on perennial branch Mar 21, 2024
@tranhl
Copy link
Author

tranhl commented Mar 21, 2024

FYI for anyone experiencing this - fixing this is as simple as removing the offending git-town-branch config item from .git/config.

@kevgo
Copy link
Contributor

kevgo commented Mar 21, 2024

Confirming that this is a bug in git switch. If a branch is listed as a perennial branch, it should be treated as such, and any parent branch set for it should be ignored.

The CLI command to remove the config entry is:

git config --unset <entry key>

In this case:

git config --unset git-town-branch.release-v1.0.0.parent

@kevgo kevgo added the bug label Mar 22, 2024
@kevgo
Copy link
Contributor

kevgo commented Mar 22, 2024

Rather than ignoring the parent entries in all Git Town commands, the correct course of action seems to remove the wrong parent entries so that they don't cause other problems as well.

@kevgo
Copy link
Contributor

kevgo commented Mar 23, 2024

This is shipped in v13. Enjoy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

2 participants