Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/commitizen/staging.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export { isClean };
* Asynchrounously determines if the staging area is clean
*/
function isClean (repoPath, done) {
exec('git diff --cached --name-only', {
exec('git diff --no-ext-diff --name-only && git diff --no-ext-diff --cached --name-only', {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could git diff-index --quiet HEAD work? 🤔 That way we only have to execute git once.

ref: https://unix.stackexchange.com/a/394674

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@LinusU The problem is that HEAD points to a commit/branch.
So, before your first commit, you will get a fatal: bad revision 'HEAD'.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, right, looks good then 👍 thanks for checking!

maxBuffer: Infinity,
cwd: repoPath || process.cwd()
}, function (error, stdout) {
Expand Down
15 changes: 13 additions & 2 deletions test/tests/staging.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,20 @@ describe('staging', function () {
staging.isClean(repoConfig.path, function (afterWriteStagingIsCleanError, afterWriteStagingIsClean) {
expect(afterWriteStagingIsCleanError).to.be.null;
expect(afterWriteStagingIsClean).to.be.false;
done();
});

writeFilesToPath({
dummymodified: {
contents: repoConfig.files.dummyfile.contents + '-modified',
filename: repoConfig.files.dummyfile.filename,
}
}, repoConfig.path);

staging.isClean(repoConfig.path, function (afterWriteStagingIsCleanError, afterWriteStagingIsClean) {
expect(afterWriteStagingIsCleanError).to.be.null;
expect(afterWriteStagingIsClean).to.be.false;
done();
});
});
});
});
});
Expand Down