lazygit icon indicating copy to clipboard operation
lazygit copied to clipboard

Finishing a Release (git flow) doesn't merge it into develop, only master

Open amatosg opened this issue 3 years ago • 7 comments

Describe the bug When I close a release using git flow, it merges into master but not into develop

To Reproduce Steps to reproduce the behavior:

  1. Use i to create a release
  2. Make any commit
  3. Close the release
  4. It will merge into master, but not into develop

Expected behavior the release should merge into master and develop

Screenshots Irrelevant

Desktop (please complete the following information):

  • OS: Arch Linux
  • Lazygit v0.31.4

amatosg avatar Dec 05 '21 00:12 amatosg

Any news on this?

aleDVirgo avatar Feb 23 '23 11:02 aleDVirgo

Are you still affected by this on v0.37?

mark2185 avatar Feb 23 '23 11:02 mark2185

Ok, I've tested now. The bug seems fixed.

+ git flow release finish 1.0.0

Switched to branch 'master'
Merge made by the 'ort' strategy.
 CHANGELOG.md | 4 ++++
 1 file changed, 4 insertions(+)
 create mode 100644 CHANGELOG.md
Already on 'master'
Switched to branch 'develop'
Merge made by the 'ort' strategy.
 CHANGELOG.md | 4 ++++
 1 file changed, 4 insertions(+)
 create mode 100644 CHANGELOG.md
Deleted branch release/1.0.0 (was e804465).

Summary of actions:
- Release branch 'release/1.0.0' has been merged into 'master'
- The release was tagged '1.0.0'
- Release tag '1.0.0' has been back-merged into 'develop'
- Release branch 'release/1.0.0' has been locally deleted
- You are now on branch 'develop'


Press enter to return to lazygit

Is there a way to include the -p option in order to push the changes also on remote??

aleDVirgo avatar Feb 23 '23 11:02 aleDVirgo

Based on a glance at the code, there doesn't seem to be a way to do that, I may be wrong tho.

Feel free to open up a feature request! :)

mark2185 avatar Feb 23 '23 12:02 mark2185

I'm not so expert in Go but I believe in the pkg/commands/git_commands/flow.go it just needs somethin like this:

-func (self *FlowCommands) FinishCmdObj(branchName string) (oscommands.ICmdObj, error) {
+func (self *FlowCommands) FinishCmdObj(branchName string, willPush bool) (oscommands.ICmdObj, error) {
	prefixes := self.config.GetGitFlowPrefixes()

	// need to find out what kind of branch this is
	prefix := strings.SplitAfterN(branchName, "/", 2)[0]
	suffix := strings.Replace(branchName, prefix, "", 1)

	branchType := ""
	for _, line := range strings.Split(strings.TrimSpace(prefixes), "\n") {
		if strings.HasPrefix(line, "gitflow.prefix.") && strings.HasSuffix(line, prefix) {
			regex := regexp.MustCompile("gitflow.prefix.([^ ]*) .*")
			matches := regex.FindAllStringSubmatch(line, 1)

			if len(matches) > 0 && len(matches[0]) > 1 {
				branchType = matches[0][1]
				break
			}
		}
	}

	if branchType == "" {
		return nil, errors.New(self.Tr.NotAGitFlowBranch)
	}

+        if willPush {
+               return self.cmd.New("git flow " + branchType + " finish -pm " + suffix), nil
+        }
	return self.cmd.New("git flow " + branchType + " finish " + suffix), nil
}

aleDVirgo avatar Feb 24 '23 09:02 aleDVirgo

Something like that, yeah.

I'd just make it configurable through config.yml, something like gitFlowFlags, so it's backwards compatible, and in case that someone doesn't want to push, nothing unexpected will happen.

mark2185 avatar Feb 24 '23 09:02 mark2185

Yep, or maybe a prompt after choosing the "feature finish"/"release finish" option asking "push changes to remote".

P.S. I've opened a feature request with my personal account, this one is just for my workplace stuff.

#2472

aleDVirgo avatar Feb 24 '23 09:02 aleDVirgo

Closing as fixed

jesseduffield avatar May 31 '23 00:05 jesseduffield