[gedit-plugins] Bug 724913 - Ignore remote files in the git plugin



commit b0a0ea0599af2eaeb5850d4ad16eb9ff4a089c07
Author: Garrett Regier <garrettregier gmail com>
Date:   Mon Mar 24 07:28:39 2014 -0700

    Bug 724913 - Ignore remote files in the git plugin

 plugins/git/git/viewactivatable.py   |   24 +++++++++++++-----------
 plugins/git/git/windowactivatable.py |    6 ++++++
 2 files changed, 19 insertions(+), 11 deletions(-)
---
diff --git a/plugins/git/git/viewactivatable.py b/plugins/git/git/viewactivatable.py
index 2426914..76060b0 100644
--- a/plugins/git/git/viewactivatable.py
+++ b/plugins/git/git/viewactivatable.py
@@ -101,18 +101,20 @@ class GitViewActivatable(GObject.Object, Gedit.ViewActivatable):
 
     def update_location(self, *args):
         self.location = self.buffer.get_location()
-        if self.location is None:
-            return
 
-        try:
-            repo_file = Ggit.Repository.discover(self.location)
-            repo = Ggit.Repository.open(repo_file)
-            head = repo.get_head()
-            commit = repo.lookup(head.get_target(), Ggit.Commit.__gtype__)
-            tree = commit.get_tree()
+        repo = None
+        if self.location is not None and self.location.has_uri_scheme('file'):
+            try:
+                repo_file = Ggit.Repository.discover(self.location)
+                repo = Ggit.Repository.open(repo_file)
+                head = repo.get_head()
+                commit = repo.lookup(head.get_target(), Ggit.Commit.__gtype__)
+                tree = commit.get_tree()
 
-        except Exception:
-            # Not a git repository
+            except Exception:
+                repo = None
+
+        if repo is None:
             if self.file_contents_list is not None:
                 self.file_contents_list = None
                 self.gutter.remove(self.diff_renderer)
diff --git a/plugins/git/git/windowactivatable.py b/plugins/git/git/windowactivatable.py
index c8ade3c..7c5b8bb 100644
--- a/plugins/git/git/windowactivatable.py
+++ b/plugins/git/git/windowactivatable.py
@@ -139,6 +139,9 @@ class GitWindowActivatable(GObject.Object, Gedit.WindowActivatable):
     def root_changed(self, bus, msg, data=None):
         self.clear_monitors()
 
+        if not msg.location.has_uri_scheme('file'):
+            return
+
         try:
             repo_file = Ggit.Repository.discover(msg.location)
             self.repo = Ggit.Repository.open(repo_file)
@@ -154,6 +157,9 @@ class GitWindowActivatable(GObject.Object, Gedit.WindowActivatable):
             self.monitor_directory(msg.location)
 
     def inserted(self, bus, msg, data=None):
+        if not msg.location.has_uri_scheme('file'):
+            return
+
         self.files[msg.location.get_uri()] = msg.id
         self.file_names[msg.location.get_uri()] = msg.name
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]