Closed swissspidy closed 1 year 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.
@wp-cli/committers Should we change the default branch on all repositories to trunk
, which would resolve this problem?
@danielbachhuber Change of default branch to main is in progress - see https://github.com/wp-cli/wp-cli/issues/5598
@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.
This should no longer be necessary as of https://github.com/wp-cli/wp-cli/issues/5598#issuecomment-1320337832
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.