Repository navigation
Infer branch for NDDB more consistently - #9328
Conversation
| if (aheadBehindOfInferredBranch === null) { | ||
| aheadBehindOfInferredBranch = await aheadBehindUpdater.executeAsyncTask( |
There was a problem hiding this comment.
This logic may change slightly once I address the comment in #9319 (comment)
| expect(branch!.upstream).toBe(branches[5].upstream) | ||
| }) | ||
|
|
||
| it('Returns the default branch of the fork if it is ahead of the current branch', async () => { |
There was a problem hiding this comment.
This test is not relevant anymore, since now the origin branch is never returned for a fork
| const aheadBehind = comparisonCache.get( | ||
| currentBranch.tip.sha, | ||
| defaultBranch.tip.sha | ||
| ) |
There was a problem hiding this comment.
This read from the cache was causing the inconsistencies: the cache is not always populated and that caused differences on the inferred branch depending on the actions that the user had taken before.
|
Based on your changes, I should expect these scenarios to work or did I miss something?
|
Exactly! that's the expected behaviour |
outofambit
left a comment
There was a problem hiding this comment.
this looks great! one question about a conditional we might be able to remove. 🎉
Co-Authored-By: evelyn masso <[email protected]>
Partially addresses #5293
This branch is based on #9320
Description
This PR changes the logic to infer the branch used for the NDDB to follow the rules that the code comments suggest:
Before, there was some logic to default to branch on
originif the current branch was behind it, but this logic didn't work correctly all the time and it caused this inconsistencies. With this PR the logic is now deterministic and a little bit simpler.Screenshots
Before:
With this fix, the inferred branch stays as
upstream/masterno matter which actions the user takes.Release notes
Notes: no-notes