def run(self):
     view = self.window.active_view()
     if not view.name().startswith(VIEW_PREFIX):
         view = createView(view.window())
     items = [basename(projectRoot(view))]
     depsdDir = join(projectRoot(view), 'deps.d')
     if not isdir(depsdDir):
         self._changeDir(items[0], view)
         return
     for f in listdir(depsdDir):
         items.append(f)
     if len(items) == 1:
         self._changeDir(items[0], view)
         return
     self.window.show_quick_panel(items, lambda x: self._changeDir(items[x], view) if x != -1 else None)
 def _changeDir(self, name, view):
     rootDir = projectRoot(view)
     if name == basename(rootDir):
         directory = rootDir
     else:
         directory = join(rootDir, 'deps.d', name)
     view.run_command('remote_git_set_root_dir', args=dict(rootDir=directory))
 def run(self, edit, **kwargs):
     args = kwargs
     view = self.view
     filename, commands = findFilenameAndCommands(view)
     if 'filename' in kwargs:
         filename = kwargs['filename']
     elif filename is None:
         filename = view.file_name()
     if filename is None:
         command, args = lastCommand(1, remove=False)
         if command == self.__class__.__name__ and args and 'filename' in args:
             filename = args['filename']
     if filename:
         args['filename'] = filename
         if 'deps.d' in filename:
             root, depsd = filename.rsplit('deps.d', 1)
             view.rootDir = "%sdeps.d/%s" % (root, depsd.split('/')[1])
         else:
             view.rootDir = projectRoot(view)
         if view.rootDir in filename:
             filename = filename.split(view.rootDir)[1][1:]
     logCommand(view, self.__class__.__name__, args)
     command = GitCommand(GIT_LOG, filename)
     if kwargs.get('patch') == True:
         command.addOption('-p')
     if filename:
         command.addOption('--follow')
     result = remoteCommand(view, command)
     view = maybeCreateView(self.view)
     view.run_command("replace_view_content", args=dict(content=result, name=LOG_VIEW_NAME))
     if hasattr(view, "lastloglineno"):
         gotoLine(view, view.lastloglineno, atTop=True)
     else:
         gotoNextCommit(view, up=False, currentLine=-1),
def remoteCommand(view, command):
    rootDir = view.rootDir if hasattr(view, 'rootDir') else projectRoot(view)
    args = ["bash", "remote_command.sh", rootDir] + ['"' + command + '"']
    proc = Popen(' '.join(args), cwd=mydir, stdout=PIPE, stderr=PIPE, stdin=PIPE, shell=True)
    try:
        stdout, stderr = proc.communicate(timeout=2)
    except TimeoutExpired:
        proc = Popen(' '.join(args), cwd=mydir, stdout=PIPE, stderr=PIPE, stdin=PIPE, shell=True)
        stdout, stderr = proc.communicate(timeout=2)
    return stdout.decode('utf-8')
 def run(self, edit, presetMessage=""):
     GIT_COMMIT_OPTIONS["options"] = self.options
     remoteCommand(self.view, GitCommand("git commit"))
     rootDir = self.view.rootDir if hasattr(self.view, "rootDir") else projectRoot(self.view)
     GIT_COMMIT_OPTIONS["rootDir"] = rootDir
     result = open(join(rootDir, ".git", "COMMIT_EDITMSG")).read().rstrip()
     command = GitCommand(GIT_DIFF)
     command.addOption("--staged")
     stagedDiff = remoteCommand(self.view, command)
     if not stagedDiff.strip():
         message_dialog("You have nothing staged for commit")
         return
     commitRegion = Region(len(presetMessage), len(result))
     result += "\n" + stagedDiff.strip()
     view = replaceView(self.view, edit, presetMessage + result, name=COMMIT_EDITMSG_VIEW_NAME)
     view.sel().clear()
     view.sel().add(Region(0, 0))
     view.set_read_only(False)
     view.add_regions(COMMIT_EDITMSG_VIEW_NAME, [commitRegion])
Beispiel #6
0
 def _checkoutProject(self, i, projects):
     if i == -1:
         return
     depsDdir = join(projectRoot(self.view), "deps.d")
     isdir(depsDdir) or makedirs(depsDdir)
     executeCommand(view=self.view, args=["seecr-git-clone {}".format(projects[i])], projectCwd="deps.d")
 def run(self, edit):
     currentLine = currentLineText(self.view)
     filename, lineno, _ = currentLine.split(":", 2)
     filepath = "{0}/{1}:{2}".format(projectRoot(self.view), filename, lineno)
     self.view.window().open_file(filepath, ENCODED_POSITION)