mirror of
https://github.com/atom/atom.git
synced 2026-01-23 22:08:08 -05:00
@@ -9,6 +9,7 @@ var $git = {};
|
||||
native function checkoutHead(path);
|
||||
native function getDiffStats(path);
|
||||
native function isSubmodule(path);
|
||||
native function refreshIndex();
|
||||
|
||||
function GitRepository(path) {
|
||||
var repo = getRepository(path);
|
||||
@@ -24,5 +25,6 @@ var $git = {};
|
||||
GitRepository.prototype.checkoutHead = checkoutHead;
|
||||
GitRepository.prototype.getDiffStats = getDiffStats;
|
||||
GitRepository.prototype.isSubmodule = isSubmodule;
|
||||
GitRepository.prototype.refreshIndex = refreshIndex;
|
||||
this.GitRepository = GitRepository;
|
||||
})();
|
||||
|
||||
@@ -69,12 +69,6 @@ public:
|
||||
return CefV8Value::CreateInt(0);
|
||||
}
|
||||
|
||||
git_index* index;
|
||||
if (git_repository_index(&index, repo) == GIT_OK) {
|
||||
git_index_read(index);
|
||||
git_index_free(index);
|
||||
}
|
||||
|
||||
unsigned int status = 0;
|
||||
if (git_status_file(&status, repo, path) == GIT_OK) {
|
||||
return CefV8Value::CreateInt(status);
|
||||
@@ -192,7 +186,6 @@ public:
|
||||
BOOL isSubmodule = false;
|
||||
git_index* index;
|
||||
if (git_repository_index(&index, repo) == GIT_OK) {
|
||||
git_index_read(index);
|
||||
const git_index_entry *entry = git_index_get_bypath(index, path, 0);
|
||||
isSubmodule = entry != NULL && (entry->mode & S_IFMT) == GIT_FILEMODE_COMMIT;
|
||||
git_index_free(index);
|
||||
@@ -201,6 +194,14 @@ public:
|
||||
return CefV8Value::CreateBool(isSubmodule);
|
||||
}
|
||||
|
||||
void RefreshIndex() {
|
||||
git_index* index;
|
||||
if (exists && git_repository_index(&index, repo) == GIT_OK) {
|
||||
git_index_read(index);
|
||||
git_index_free(index);
|
||||
}
|
||||
}
|
||||
|
||||
IMPLEMENT_REFCOUNTING(GitRepository);
|
||||
};
|
||||
|
||||
@@ -264,6 +265,12 @@ bool Git::Execute(const CefString& name,
|
||||
return true;
|
||||
}
|
||||
|
||||
if (name == "refreshIndex") {
|
||||
GitRepository *userData = (GitRepository *)object->GetUserData().get();
|
||||
userData->RefreshIndex();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
$ = require 'jquery'
|
||||
|
||||
module.exports =
|
||||
class Git
|
||||
|
||||
@@ -15,6 +17,9 @@ class Git
|
||||
|
||||
constructor: (path) ->
|
||||
@repo = new GitRepository(path)
|
||||
$(window).on 'focus', => @refreshIndex()
|
||||
|
||||
refreshIndex: -> @repo.refreshIndex()
|
||||
|
||||
getPath: -> @repo.getPath()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user