wp-cli / wp-cli-dev

🛠 WP-CLI development environment that allows for easy development across all packages
36 stars 36 forks source link

Detect default branch name in refresh-repository.php #25

Closed swissspidy closed 1 year ago

swissspidy commented 2 years ago

Feature Request

- [x] Yes, I reviewed the [contribution guidelines](https://make.wordpress.org/cli/handbook/contributing/). **Describe your use case and the problem you are facing** Some commands still use a `master` branch while some use `main` `refresh-repository.php` has `master` hardcoded though: https://github.com/wp-cli/wp-cli-dev/blob/c040d8e24dfea5b696d73c5306f6f3d1b8e8f546/.maintenance/refresh-repository.php#L12-L13 **Describe the solution you'd like** Detect which branch is the default and use that instead of hardcoded `master`. Locally I use a command like `git checkout $(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')` to achieve this.
wojsmol commented 2 years ago

This can be also retrieved using curl -s https://api.github.com/repos/wp-cli/{$repository} | jq --raw-output .default_branch if jq dependency is acceptable.

danielbachhuber commented 2 years ago

@wp-cli/committers Should we change the default branch on all repositories to trunk, which would resolve this problem?

wojsmol commented 2 years ago

@danielbachhuber Change of default branch to main is in progress - see https://github.com/wp-cli/wp-cli/issues/5598

danielbachhuber commented 2 years ago

@swissspidy Detecting the default branch seems like a good enhancement while we wait for https://github.com/wp-cli/wp-cli/issues/5598 to be completed.

danielbachhuber commented 1 year ago

This should no longer be necessary as of https://github.com/wp-cli/wp-cli/issues/5598#issuecomment-1320337832