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

Conversation

@annthurium
Copy link

@annthurium 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.

});
it('is disabled if pullRequest.headRepository is null', function() {
const props = issueishDetailControllerProps({}, {});
props.repository.pullRequest.headRepository = null;
Copy link
Author

Choose a reason for hiding this comment

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

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.

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.

👍 Yup yup.

@annthurium annthurium merged commit 2246691 into master Dec 6, 2018
@annthurium annthurium deleted the tt-18-dec-fix-view-pr branch December 6, 2018 19:50
smashwilson pushed a commit that referenced this pull request Jan 4, 2019
Fix bug where pull request cannot be viewed if pullRequest.headRepository is null.
@smashwilson smashwilson mentioned this pull request Jan 4, 2019
5 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.

3 participants