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

Detect upstream git branch based on git config #114

Open
ThisIsMissEm opened this issue Sep 21, 2020 · 1 comment
Open

Detect upstream git branch based on git config #114

ThisIsMissEm opened this issue Sep 21, 2020 · 1 comment

Comments

@ThisIsMissEm
Copy link

Currently, this tool hardcodes the usage of master as the upstream branch, which can often not be the case.

https://github.com/azz/pretty-quick/blob/master/src/scms/git.js#L31-L37

const revision = staged
      ? 'HEAD'
      : runGit(directory, [
          'merge-base',
          'HEAD',
          branch || 'master',
        ]).stdout.trim();

You can potentially provide better user experience by first checking if the user has configured a different default branch for their repos: git config --get init.defaultbranch, if that returns a value, then use that value, otherwise, use master (or if you wanna be progressive, main, but that'd be a breaking change — n.b., GitHub has published intent to change the default branch to always be main not master: https://github.com/github/renaming )

@JounQin
Copy link
Member

JounQin commented Jan 16, 2024

Yes, it can be improved, currently you can use --branch option to override.

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

No branches or pull requests

2 participants