def getDocState(self): uri = self.doc.get_uri_for_display() cwd = os.path.dirname(uri) bname = os.path.basename(uri) self.inGitDir = False self.isCached = False self.HEAD2index = None self.index2WT = None if not self.doc.is_untitled(): # subPro = subprocess.Popen(["git ls-files",os.path.basename(uri)],stdout=subprocess.PIPE,stderr=subprocess.STDOUT,cwd=cwd,shell=True) (returncode, statusStr, errStr) = gitRun("ls-files", os.path.basename(uri), cwd) if returncode == 0: self.inGitDir = True if statusStr != "": self.isCached = True # statusStr = subprocess.Popen(["git diff","--cached","--name-status",os.path.basename(uri)],stdout=subprocess.PIPE,cwd=cwd,shell=True).communicate()[0] statusStr = gitRun("diff", ["--cached", "--name-status", os.path.basename(uri)], cwd)[1] if statusStr != "": status = statusStr[:-1].split()[0] self.HEAD2index = status # statusStr = subprocess.Popen(["git diff","--name-status",os.path.basename(uri)],stdout=subprocess.PIPE,cwd=cwd,shell=True).communicate()[0] statusStr = gitRun("diff", ["--name-status", os.path.basename(uri)], cwd)[1] if statusStr != "": status = statusStr[:-1].split()[0] self.index2WT = status pass
def commit_current_file(self, button, window): fileUri = window.get_active_tab().get_document().get_uri_for_display() text = self.plugin.windowHelpers[window].docBar.commit_text.get_text() self.plugin.windowHelpers[window].docBar.commit_text.set_text("") if text != "": gitRun("commit", ['-m "' + text + '"', os.path.basename(fileUri)], os.path.dirname(fileUri)) window.emit("active-tab-state-changed") else: self.commitDialog.run(window, fileUri, False)
def on_commit_button_clicked(self, close_button): commit_text_buffer = self.commit_text_box.get_buffer() commit_text = commit_text_buffer.get_text(commit_text_buffer.get_start_iter(),commit_text_buffer.get_end_iter()) if self.fileName : gitRun('commit',['-m "'+commit_text+'"',self.fileName],self.cwd) else: gitRun('commit',[' -m "'+commit_text+'"'],self.cwd) commit_text_buffer.set_text("") self.commit_dialog.hide() self.current_window.emit("active-tab-state-changed") self.current_window = None pass
def diff_index_wt(self, button, window): fileUri = window.get_active_tab().get_document().get_uri_for_display() gitRun("difftool", ["--tool=meld", "--no-prompt", os.path.basename(fileUri)], os.path.dirname(fileUri)) pass
def add(self, button, window): fileUri = window.get_active_tab().get_document().get_uri_for_display() gitRun("add", os.path.basename(fileUri), os.path.dirname(fileUri)) window.emit("active-tab-state-changed") pass