Return repository for all paths

This commit is contained in:
Kevin Sawicki
2012-10-25 14:20:45 -07:00
committed by Corey Johnson
parent 4c80b1e4ef
commit a3ef53f8e6
4 changed files with 3 additions and 23 deletions

View File

@@ -1,9 +1,6 @@
var $git = {};
(function() {
native function getRepositoryPath(path);
$git.getRepositoryPath = getRepositoryPath;
native function getRepository(path);
native function getHead();

View File

@@ -13,7 +13,7 @@ class GitRepository : public CefBase {
public:
GitRepository(CefRefPtr<CefV8Value> path) {
const char *repoPath = path->GetStringValue().ToString().c_str();
exists = git_repository_open(&repo, repoPath) == GIT_OK;
exists = git_repository_open_ext(&repo, repoPath, 0, NULL) == GIT_OK;
}
~GitRepository() {
@@ -54,17 +54,6 @@ bool Git::Execute(const CefString& name,
const CefV8ValueList& arguments,
CefRefPtr<CefV8Value>& retval,
CefString& exception) {
if (name == "getRepositoryPath") {
const char *path = arguments[0]->GetStringValue().ToString().c_str();
int length = strlen(path);
char repoPath[GIT_PATH_MAX];
if (git_repository_discover(repoPath, length, path, 0, "") == GIT_OK)
retval = CefV8Value::CreateString(repoPath);
else
retval = CefV8Value::CreateNull();
return true;
}
if (name == "getRepository") {
CefRefPtr<CefBase> userData = new GitRepository(arguments[0]);
retval = CefV8Value::CreateObject(NULL);

View File

@@ -1,10 +1,6 @@
module.exports =
class Git
@open: (path) ->
repoPath = $git.getRepositoryPath(path)
new Git(repoPath) if repoPath
constructor: (@repoPath) ->
@repo = new GitRepository(@repoPath)

View File

@@ -56,7 +56,7 @@ class StatusBar extends View
updateBranchText: ->
if path = @editor.getPath()
@head = Git.open(path)?.getShortHead()
@head = new Git(path).getShortHead()
else
@head = null
@@ -67,9 +67,7 @@ class StatusBar extends View
@branchArea.hide()
updatePathText: ->
path = @editor.getPath()
if path
@head = Git.open(path)?.getShortHead()
if path = @editor.getPath()
@currentPath.text(@rootView.project.relativize(path))
else
@currentPath.text('untitled')