mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Add $git.isRepository
This commit is contained in:
committed by
Corey Johnson
parent
55063d61ec
commit
1b42bd9662
@@ -1,4 +1,6 @@
|
||||
var $git = {};
|
||||
(function() {
|
||||
|
||||
native function isRepository(path);
|
||||
$git.isRepository = isRepository;
|
||||
})();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user