Repository navigation
Adds logic that determines what branch to use as the compare branch (NDDB) - #4783
Conversation
This is mostly exploratory, the logic is most likely wrong at this stage.
Deferring the decision of which piece of the branch to use to the user
This may be wrong, but the docs in `/models/branc` make knowing which one to use difficult
I wanted to make sure the function could not be passed a set of arguments that would lead to unexpected behavior.
I'm okay with punting on the One thing to note is that the "default branch" doesn't necessarily mean "master". For example, the default branch could be "development" or "gh-pages" in some cases. If that's the case, then that should be the branch we compare against for the notification. I wasn't able to tell by reading the code, but are we supporting this scenario? |
|
@donokuda, yes, that case is currently being supported. In situations where a default branch has not been set, we default to |
|
🥇 |
nerdneha
left a comment
There was a problem hiding this comment.
So close to the finish line! Great changes
| branches: ReadonlyArray<Branch>, | ||
| repository: Repository, | ||
| currentPullRequest: PullRequest | null, | ||
| currentBranch: Branch | null, |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| } | ||
|
|
||
| /** | ||
| * For `inferComparisonBranch` case where inferring for a pull request |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| * @param branches The list of all branches for the repository | ||
| * @param repository The repository the branch belongs to | ||
| * @param ghRepository The github specific information for the repository | ||
| * @param currentBranch The branch we want the parent of |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| ): Promise<Branch | null> { | ||
| const defaultBranchName = ghRepository.defaultBranch | ||
|
|
||
| if (defaultBranchName === null) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| * @param branches The list of all branches for the repository | ||
| * @param ghRepository The repository the branch belongs to | ||
| */ | ||
| function _getDefaultBranchOfGithubRepo( |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
@iAmWillShepherd should we also a unit test for the |
Not sure I understand this one. Is the expectation that we return the parent branch (not sure of the proper Git terminology here)? I'll admit my current understanding of this is flaky, but I was under the impression that you can only check if a commit is a child of the tip of the current branch. Wouldn't this mean we can't reliably tell what the parent branch would be? Can anyone in @desktop/eng provide some insight on this? |
|
💯 |
Fixes #4766
This PR encapsulates the logic detailed in the issue inside of a function.
Some notes up front, I'm not sure of the actual place this functions belongs, so I put it next to related functions. Since it's self contained, it shouldn't be a huge deal to move it to a better place.