New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug where pull request cannot be viewed if pullRequest.headRepository is null. #1828

Merged
merged 2 commits into from Dec 6, 2018

Conversation

2 participants
@annthurium
Copy link
Contributor

annthurium commented Dec 6, 2018

Description of the Change

If pullRequest.headRepository is null, (which might be the case if, for example, a user deletes the repository), currently we throw an error and the pull request cannot be viewed.

This pull request adds a check for this condition, so we can avoid the code that's checking for a non existent property.

Alternate Designs

This approach allows a user to view a pull request where a head repository is null, but they cannot check it out. While it would be possible to fall back to refs/pull/${PR}/head to check out the pull request from dotcom, it seems not worth the added complexity. My assumption is, it's relatively rare for a user to open a cross repository pull request and then delete their fork.

If I'm wrong, and it's more common than I think, I'd be open to revisiting this decision and supporting checkout in this edge case.

Benefits

Users can view pull requests again.

Possible Drawbacks

I can't think of anything, other than writing code always introduces the possibility of more bugs.

Applicable Issues

#1776

Metrics

n/a

Tests

  • Wrote a unit test to validate that the checkout opportunity is disabled if pullRequest.headRepository is null.
  • Manually testing viewing a pull request within Atom where the head repository has been deleted.

Documentation

N/A

Release Notes

It's not a notable change, dawg. Nothing to see here.

@@ -109,6 +109,15 @@ describe('IssueishDetailController', function() {
assert.isFalse(op1.isEnabled());
assert.strictEqual(op1.getMessage(), 'Rebase in progress');
});
it('is disabled if pullRequest.headRepository is null', function() {
const props = issueishDetailControllerProps({}, {});
props.repository.pullRequest.headRepository = null;

This comment has been minimized.

@annthurium

annthurium Dec 6, 2018

Contributor

I...I don't love this, but also, the way the test factories are currently set up, you can't supply a parameter to our test factories that makes an entire nested part of the Relay response null. We should probably come up with a better pattern for these factories.

@smashwilson
Copy link
Member

smashwilson left a comment

👍 Yup yup.

Stability Sprint : 20 November 2018 - 8 January 2019 : v0.24.0 automation moved this from In Progress 🔧 to QA Review 🔬 Dec 6, 2018

@annthurium annthurium merged commit 2246691 into master Dec 6, 2018

3 checks passed

codecov/changes No unexpected coverage changes found.
Details
codecov/patch Coverage not affected when comparing 55a6d63...a0d8f8c
Details
codecov/project 89.52% (+<.01%) compared to 55a6d63
Details

Stability Sprint : 20 November 2018 - 8 January 2019 : v0.24.0 automation moved this from QA Review 🔬 to Merged ☑️ Dec 6, 2018

@annthurium annthurium deleted the tt-18-dec-fix-view-pr branch Dec 6, 2018

smashwilson added a commit that referenced this pull request Jan 4, 2019

Merge pull request #1828 from atom/tt-18-dec-fix-view-pr
Fix bug where pull request cannot be viewed if pullRequest.headRepository is null.

@smashwilson smashwilson referenced this pull request Jan 4, 2019

Closed

v0.23.2-0 QA Review #1883

5 of 5 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment