ing-bank/doing-cli

Add the capability to define the merge type for automatic completion

FitzgeraldKrudde opened this issue · 5 comments

Now it uses the default (merge (no fast forward)) but we prefer rebase and fast-forward.

Probably the command az repos policy merge-strategy create is needed with the branch name and the parameter --allow-rebase true

My compliments for a great tool! Just what/how I like it!

Really good suggestion.

Looking at the docs now, the merge strategy seems a repository-based policy, because you cannot specify it with az repos pr create.

You can set these things (as you suggested) with az repos policy merge-strategy create. That might mean every doing command should first az repos policy list and then potentially az repos policy merge-strategy update, which will add some latency.

I'll pick this up next iteration I make on doing-cli.

This is trickier than I thought. az repos pr create has no option to specify the merge type, so the only solution would be to disallow all other merge strategies other than the one your team prefers (that's what the blogpost introducing the feature suggests).

Github actually works the same way "You can enforce one type of merge method, such as commit squashing or rebasing, by only enabling the desired method for your repository." (source). And gh pr create also has no merge strategy option.

By default, azure devops will use the 'Merge (no fast-forward)' strategy. So if the users would allow for multiple merge strategies (via az repos policy merge-strategy create), there's no way to select which one doing pr create would use.

I see two design directions here. 1) doing create pr --merge-strategy where you specify one of the four merge methods, and internally, we check, create/update the policy to only allow for that merge strategy. Upside is that it is easy to understand for users, and you can set a default value for the --merge-strategy in the doing config. Downside: if not all users on the project use doing the entire time, you keep changing the allowed merge-strategies in the UI.

  1. A new merge-strategy option in .doing-cli-config where you specify one of the four merge methods. Everytime you run doing create pr it will create or update a policy to only allow for that merge method. Upside: 1 place to specify this setting, we keep doing more consistent with the github CLI, and you force upon your team mates prefer using the UI the merge strategy best practice. Downside: some extra commands to run at doing pr create that add extra latency. And you now do not have the option to allow for multiple merge-strategies in the UI.

I'm inclined to implement 2). If we set the merge-strategy default as None (also when not specified), we won't bother with the policies and use whatever is defined already. If a merge-strategy is specified, we'll check and update the policies everything to make sure we disallow for others.

There's also the squash commits option. az repos pr create has a --squash option, but gh pr create does not. I'm going to leave out the --squash option and let users do that via the UI. And for CLI users, good chance they savvy enough to git rebase -i.

Any thoughts?

This is indeed a bit tricky, IMHO unnecessary tricky: I would have added the option to set the merge strategy for az repos pr create. This appears over-designed to me by MS. But we have to handle it for now I am afraid..

Option 2 looks fine to me! I would not mind a bit extra latency during the creation of the PR.

Support was added in the just released v1.2.

Read more about the new merge_strategy option in the docs: https://ing-bank.github.io/doing-cli/config/config_file/#setting-merge_strategy

Great, very nice! Thanks!