mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Return repository for all paths
This commit is contained in:
committed by
Corey Johnson
parent
4c80b1e4ef
commit
a3ef53f8e6
@@ -1,9 +1,6 @@
|
||||
var $git = {};
|
||||
(function() {
|
||||
|
||||
native function getRepositoryPath(path);
|
||||
$git.getRepositoryPath = getRepositoryPath;
|
||||
|
||||
native function getRepository(path);
|
||||
native function getHead();
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user