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

Commit

Permalink
Merge pull request #506 from atom/ku-fix-amend-mode-unstaged-changes-…
Browse files Browse the repository at this point in the history
…diff

Fix staging line selection while in amend mode
  • Loading branch information
kuychaco authored Feb 7, 2017
2 parents b534809 + 21ae281 commit 8e09a04
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/controllers/git-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,8 @@ export default class GitController extends React.Component {
const repository = this.props.repository;
if (!repository) { return null; }

const filePatch = await repository.getFilePatchForPath(filePath, {staged: stagingStatus === 'staged', amending});
const staged = stagingStatus === 'staged';
const filePatch = await repository.getFilePatchForPath(filePath, {staged, amending: staged && amending});
return new Promise(resolve => {
if (filePatch) {
this.setState({filePath, filePatch, stagingStatus}, () => {
Expand Down
14 changes: 14 additions & 0 deletions test/controllers/git-controller.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,20 @@ describe('GitController', function() {
assert.notEqual(originalFilePatch, wrapper.state('filePatch'));
});
});

// https://github.com/atom/github/issues/505
it('calls repository.getFilePatchForPath with amending: true only if staging status is staged', async () => {
const workdirPath = await cloneRepository('three-files');
const repository = await buildRepository(workdirPath);

app = React.cloneElement(app, {repository});
const wrapper = shallow(app);

sinon.stub(repository, 'getFilePatchForPath');
await wrapper.instance().showFilePatchForPath('a.txt', 'unstaged', {amending: true});
assert.equal(repository.getFilePatchForPath.callCount, 1);
assert.deepEqual(repository.getFilePatchForPath.args[0], ['a.txt', {staged: false, amending: false}]);
});
});

describe('diveIntoFilePatchForPath(filePath, staged, {amending, activate})', function() {
Expand Down

0 comments on commit 8e09a04

Please sign in to comment.