Add $git.isRepository

This commit is contained in:
Kevin Sawicki
2012-10-24 17:53:33 -07:00
committed by Corey Johnson
parent 55063d61ec
commit 1b42bd9662
2 changed files with 12 additions and 0 deletions

View File

@@ -1,4 +1,6 @@
var $git = {};
(function() {
native function isRepository(path);
$git.isRepository = isRepository;
})();

View File

@@ -16,6 +16,16 @@ bool Git::Execute(const CefString& name,
const CefV8ValueList& arguments,
CefRefPtr<CefV8Value>& retval,
CefString& exception) {
if (name == "isRepository") {
const char *path = arguments[0]->GetStringValue().ToString().c_str();
int length = strlen(path);
char repoPath[length];
bool isRepository = git_repository_discover(repoPath, length, path, 0, "") == GIT_OK;
retval = CefV8Value::CreateBool(isRepository);
return true;
}
return false;
}
}