Bitbucket PR creation ignores branching model development branch
Summary
T3Code currently creates Bitbucket pull requests against the repository main branch (main) even when the repository's Bitbucket branching model has a separate development branch (develop).
This is surprising because Bitbucket stores the development branch separately from the repository main/production branch, and in this repository the intended day-to-day integration branch is develop.
Setup
Bitbucket repository branching model:
- Development branch:
develop(Use specific branch) - Production branch:
main(Use main branch) - Branch prefixes include
feature/,bugfix/,hotfix/, andrelease/
Current behavior
Creating a pull request from T3Code targets main.
Adding this local git config fixes the immediate behavior for the current branch:
git config branch.$(git branch --show-current).gh-merge-base develop
Without that override, T3Code falls back to main.
Expected behavior
T3Code should not assume Bitbucket's repository mainbranch is always the appropriate pull request target branch.
For Bitbucket repositories where the branching model has a specific development branch configured, T3Code should either:
- use the branching model development branch as the default change-request target when appropriate, or
- expose/configure a separate default pull-request target branch instead of relying only on the repository main branch.
Likely cause
The Bitbucket provider currently resolves the default branch from the repository payload's mainbranch field:
getDefaultBranch: (input) =>
getRepository(input).pipe(Effect.map((repository) => repository.mainbranch?.name ?? null)),
That field returns the repository main branch (main) and does not include the Bitbucket branching model development branch.
PR creation then uses the resolved base branch as the Bitbucket pull request destination branch:
destination: {
branch: {
name: input.target?.refName ?? input.baseBranch,
},
},
So a repo with main/production branch main and development branch develop ends up with T3Code-created PRs targeting main unless branch.<name>.gh-merge-base is set locally.
Possible fix
For Bitbucket, consider reading the branching model endpoint:
GET /repositories/{workspace}/{repo_slug}/branching-model
Then use that information when resolving the default change-request target. If the development branch is configured to a specific valid branch, it can be preferred for the PR base in workflows that use develop as the integration branch. If the development branch tracks the main branch, the current repository.mainbranch.name behavior still makes sense.
Another option may be to split the source-control provider API into separate concepts:
- repository default/main branch
- default change-request target branch
That would avoid overloading getDefaultBranch for providers like Bitbucket where the desired PR target can differ from the repository main branch.