Permalink
Browse files

upload dos arquivos corretos

  • Loading branch information...
1 parent 7a1560d commit a05ade84df57fdbbc8be63cebe8766d668618b11 Rafael Martins committed Feb 8, 2009
View
Binary file not shown.
View
@@ -0,0 +1,8 @@
+[Gedit Plugin]
+Loader=python
+Module=git-gedit
+IAge=2
+Name=Git Gedit
+Description=Run Git Comamnds
+Authors=Rafael Martins, Luiz Lemos
+Website=http://github
File renamed without changes.
@@ -7,6 +7,7 @@
import gconf
from gettext import gettext as _
from terminal import GitTerminalWidget
+from helpers import GitHelper
ui_str = """
<ui>
@@ -105,10 +106,8 @@ def on_open(self, *args):
self.entry = self.combo.get_children()[0]
self.entry.set_completion(self.completion)
- term = GitTerminalWidget(self.window)
- self.branch_label.set_text(term.get_branch())
-
- self.combo_branchs.append_text("rafael")
+ self.githelper = GitHelper()
+ self.branch_label.set_text(self.githelper.get_branch(self.uri))
def close_dialog(self):
self.dialog.destroy()
View
Binary file not shown.
File renamed without changes.
File renamed without changes.
View
@@ -0,0 +1,32 @@
+import os.path
+
+class GitHelper (object):
+
+ def get_git_root(self, uri):
+ base_dir = os.path.dirname(uri)
+ depth = 10
+ git_root = ''
+
+ while depth > 0:
+
+ depth -= 1
+ app_dir = os.path.join(base_dir, '.git')
+
+ if os.path.isdir(app_dir):
+ git_root = base_dir
+ break
+ else:
+ base_dir = os.path.abspath(os.path.join(base_dir, '..'))
+
+ return git_root
+
+ def get_branch(self, uri):
+ git_root = self.get_git_root(uri)
+ return git_root
+ #f = open(os.path.join(self.git_root, ".git", "HEAD"))
+ #return f.readlines()[0].split("/")[-1]
+
+ def get_all_branchs(self, uri):
+ git_root = self.get_git_root(uri)
+ diretorios = os.listdir(os.path.join(git_root, ".git", "refs", "heads"))
+ return diretorios
View
Binary file not shown.
@@ -1,15 +1,15 @@
import gtk
-#import gedit
+import gedit
import os
import os.path
from vte import Terminal
-
+from helpers import GitHelper
class GitTerminalWidget():
def __init__(self, window):
self.window = window
-
+
self.bottom = window.get_bottom_panel()
-
+
self.uri = window.get_active_document().get_uri_for_display()
self.term = Terminal()
self.term.set_emulation("xterm")
@@ -30,7 +30,6 @@ def __init__(self, window):
self.container = gtk.VBox(False)
- # self.term.connect("child-exited", lambda term: term.fork_command('irb'))
self.term.connect("child-exited", self.close_term_action_child_exited)
self.table = gtk.Table(2,1,False)
@@ -51,27 +50,17 @@ def close(self):
self.bottom.remove_item(self.container)
self.bottom.hide()
self.container.destroy()
-
- def get_branch(self):
- self.git_root = self.get_git_root(self.uri)
- f = open(os.path.join(self.git_root,".git", "HEAD"))
- return f.readlines()[0].split("/")[-1]
-
- def get_all_branchs(self):
- self.git_root = self.get_git_root(self.uri)
- diretorios = os.listdir(os.path.join(self.git_root,".git", "refs", "heads"))
- return diretorios
-
def run(self,command=''):
- self.git_root = self.get_git_root(self.uri)
-
+ githelper = GitHelper()
+ self.git_root = githelper.get_git_root(self.uri)
+
if self.git_root=='':
os.popen("notify-send -t 1600 -i gtk-dialog-info 'Alert!' 'Open a git project file before'")
elif command.strip()=='':
os.popen("notify-send -t 1600 -i gtk-dialog-info 'Alert!' 'Hey, type something!'")
else:
- self.git_root = self.get_git_root(self.uri)
+
self.term.feed_child("cd "+self.git_root+" \n")
self.term.feed_child(command+"\n")
@@ -84,17 +73,4 @@ def run(self,command=''):
self.bottom.activate_item(self.container)
self.term.grab_focus()
- def get_git_root(self, uri):
- base_dir = os.path.dirname(uri)
- depth = 10
- git_root = ''
- while depth > 0:
- depth -= 1
- app_dir = os.path.join(base_dir, '.git')
- if os.path.isdir(app_dir):
- git_root = base_dir
- break
- else:
- base_dir = os.path.abspath(os.path.join(base_dir, '..'))
-
- return git_root
+
View
Binary file not shown.
View
Binary file not shown.

0 comments on commit a05ade8

Please sign in to comment.