jhillyerd / plugin-git

Git aliases plugin for the Fish shell (similar to oh-my-zsh git)
MIT License
607 stars 85 forks source link

Use `main` as default branch and `master` as fall back #66

Closed okuuva closed 2 years ago

okuuva commented 3 years ago

I absolutely love the fact that this plugin supports both master and main as the default branch name and while the current default behaviour (check if master exists, use that if it does, otherwise fall back to main) works about 99.9% of the time I'd like to propose to flip the logic around to support the remaining 0.1%.

One repo where I'm an active contributor recently made the change from master to main since there was a big backwards incompatible change incoming anyway and seemed like a good idea to change the default branch name at the same time. master was left as an archive. Which means I really can't use the abbreviations anymore since they keep pointing to master since it still exists.

I know this is a very rare corner case but I think it still would make sense. It's simple enough a change and I guess the other corner case (where both master and main branches exist in the repo but master is the default) is even rarer.

okuuva commented 3 years ago

I just realised the plugin respects init.defaultBranch if it's set. Works for me but still made the PR while I was at it

jhillyerd commented 3 years ago

Thanks for raising this. I agree with your reasoning, but let's keep this open for a bit and see if anyone else can cite projects that would be negatively impacted. If not, I'll merge #67 in early October.

We should also document that we respect the defaultBranch setting, since it's not obvious and I'm not sure many people are aware that setting even exists.

okuuva commented 2 years ago

We should also document that we respect the defaultBranch setting, since it's not obvious and I'm not sure many people are aware that setting even exists.

@jhillyerd I added a short description of how the default branch name is resolved to the readme in #67. I also changed all the references of master to (__git.default_branch) in the command descriptions in usage section. WDYT?

jhillyerd commented 2 years ago

Looks good, given there were no objections, I have merged #67.