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

Commit de3fb23

Browse files
Tilde Ann Thuriumsmashwilson
authored andcommitted
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.
1 parent 45f97a4 commit de3fb23

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

lib/controllers/issueish-detail-controller.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@ export class BareIssueishDetailController extends React.Component {
121121
return this.checkoutOp.disable(checkoutStates.DISABLED, 'Checking out...');
122122
}
123123

124+
// determine if pullRequest.headRepository is null
125+
// this can happen if a repository has been deleted.
126+
if (!pullRequest.headRepository) {
127+
return this.checkoutOp.disable(checkoutStates.DISABLED, 'Pull request head repository does not exist');
128+
}
129+
124130
// Determine if we already have this PR checked out.
125131

126132
const headPush = this.props.branches.getHeadBranch().getPush();

test/controllers/issueish-detail-controller.test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,15 @@ describe('IssueishDetailController', function() {
110110
assert.isFalse(op1.isEnabled());
111111
assert.strictEqual(op1.getMessage(), 'Rebase in progress');
112112
});
113+
it('is disabled if pullRequest.headRepository is null', function() {
114+
const props = issueishDetailControllerProps({}, {});
115+
props.repository.pullRequest.headRepository = null;
116+
const wrapper = shallow(buildApp({}, {...props}));
117+
const op = wrapper.find('Relay(BarePullRequestDetailView)').prop('checkoutOp');
118+
assert.isFalse(op.isEnabled());
119+
assert.strictEqual(op.getMessage(), 'Pull request head repository does not exist');
120+
});
121+
113122

114123
it('is disabled if the current branch already corresponds to the pull request', function() {
115124
const upstream = Branch.createRemoteTracking('remotes/origin/feature', 'origin', 'refs/heads/feature');

0 commit comments

Comments
 (0)