Skip to content

Detect upstream git branch based on git config #114

@ThisIsMissEm

Description

@ThisIsMissEm

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 )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions