Skip to content

Commit

Permalink
fix: add simple-git dependency, use it when checking for tracked files (
Browse files Browse the repository at this point in the history
#99)

Progress toward #86
Progress toward #98

First step in moving off of nodegit, mostly taken from @refack's branch from #86.
  • Loading branch information
alangpierce authored Apr 17, 2017
1 parent 985811c commit 4f79905
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"mz": "^2.4.0",
"nodegit": "^0.16.0",
"opn": "^4.0.2",
"require-uncached": "^1.0.2"
"require-uncached": "^1.0.2",
"simple-git": "^1.70.0"
}
}
5 changes: 2 additions & 3 deletions src/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import runWithProgressBar from './runner/runWithProgressBar';
import CLIError from './util/CLIError';
import execLive from './util/execLive';
import getFilesUnderPath from './util/getFilesUnderPath';
import gitTrackedStatus from './util/gitTrackedStatus';
import isWorktreeEmpty from './util/isWorktreeEmpty';
import makeCommit from './util/makeCommit';
import pluralize from './util/pluralize';

Expand Down Expand Up @@ -164,8 +164,7 @@ Re-run with the "check" command for more details.`);
}

async function assertGitWorktreeClean() {
let changedFiles = await gitTrackedStatus();
if (changedFiles.length) {
if (!await isWorktreeEmpty()) {
throw new CLIError(`\
You have modifications to your git worktree.
Please revert or commit them before running convert.`);
Expand Down
9 changes: 0 additions & 9 deletions src/util/gitTrackedStatus.js

This file was deleted.

9 changes: 9 additions & 0 deletions src/util/isWorktreeEmpty.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import git from 'simple-git/promise';

/**
* Determine if there are any uncommitted changes in the git state.
*/
export default async function isWorktreeEmpty() {
const status = await git().status();
return status.files.length === 0;
}

0 comments on commit 4f79905

Please sign in to comment.