Skip to content

Instantly share code, notes, and snippets.

@gimmi
Created September 27, 2011 15:30
Show Gist options
  • Save gimmi/1245381 to your computer and use it in GitHub Desktop.
Save gimmi/1245381 to your computer and use it in GitHub Desktop.
JSMake Git
jsmake.git = {};
jsmake.git.GitUtils = {
getLastCommitInfo: function (gitRepoPath) {
var git = new org.eclipse.jgit.api.Git(new org.eclipse.jgit.storage.file.FileRepository(jsmake.Fs.combinePaths(gitRepoPath, '.git')));
var commit = git.log().call().iterator().next();
return {
message: commit.getFullMessage(),
sha1: commit.getName(),
date: new Date(1000 * commit.getCommitTime())
};
},
hasUncommittedChanges: function (gitRepoPath) {
var git = new org.eclipse.jgit.api.Git(new org.eclipse.jgit.storage.file.FileRepository(jsmake.Fs.combinePaths(gitRepoPath, '.git')));
var status = git.status().call();
return !status.getChanged().isEmpty()
|| !status.getMissing().isEmpty()
|| !status.getAdded().isEmpty()
|| !status.getModified().isEmpty()
|| !status.getRemoved().isEmpty()
|| !status.getUntracked().isEmpty();
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment