Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Fix: handle branch names mismatch #1708

Merged
merged 13 commits into from
Oct 1, 2018
Merged

Conversation

vanessayuenn
Copy link
Contributor

Description of the Change

This PR introduces the use of refspec in push and pull operations (fetch does it a bit differently), in order to handle situations where the local branch is named differently from its tracking branch. This set of circumstances has become less of an edge case since the introduction of PR-checkout -- we prefix the branch name with PR number, etc.

Benefits

  • Able to fetch, pull, push checked out PRs
  • Able to be creative in naming your local branches 👯

Possible Drawbacks

This PR changes how the underlying git operations work, which is used by many things in the package; so the possible setback is if things break in edge cases that I haven't thought of.

Applicable Issues

fixes: #1697
fixes: #918

Metrics

N/A

Tests

Added unit tests to verify that push & pull & fetch work as expected despite the difference between local branch name and its upstream branch name.

Manually tested push & pull & fetch operations in these cases:

  • local branch named differently from upstream
  • local branch named the same as upstream
  • checked out PR from a branch in the original repo
  • checked out PR opened from a forked repo

@coveralls
Copy link

coveralls commented Sep 27, 2018

Coverage Status

Coverage increased (+0.08%) to 82.028% when pulling a1324c5 on vy/handle-branch-names-mismatch into 7950c43 on master.

Copy link
Contributor

@smashwilson smashwilson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link

@annthurium annthurium left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice work! Thanks for taking this on.

.instance()
.pull(await wrapper.instance().fetchData(repository))();
const postPullSHA = await repository.git.exec(['rev-parse', 'HEAD']);
assert.isTrue(repository.pull.called);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: do you want to assert that repository.pull was called with the args you expect?

.instance()
.push(await wrapper.instance().fetchData(repository))();
const remoteSHA = await repository.git.exec(['rev-parse', 'origin/master']);
assert.isTrue(repository.push.called);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same nit as above - might be good to specify which args push should be called with.

@vanessayuenn vanessayuenn merged commit 46afadd into master Oct 1, 2018
@vanessayuenn vanessayuenn deleted the vy/handle-branch-names-mismatch branch October 1, 2018 14:47
@annthurium annthurium mentioned this pull request Oct 20, 2018
7 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot handle local branch being named differently from its remote branch Pulling the tracking git branch via UI causes error
4 participants