def foreachDependency(self, command, recursive=False): if (self.config == None): return runCommand = command if (runCommand.startswith('!sh ')): runCommand = command[4:] i = runCommand.index(' ') task = Task(runCommand[:i]) runCommand = runCommand[i + 1:] else: task = Task('git') for p in self.config.sections(): d = GitDependenciesRepository(self.config[p]['url'], os.path.join(self.repositoryPath, p)) wd = os.getcwd() os.chdir(d.repositoryPath) task.run(runCommand.split(' ')) if (task.output != ''): print(task.output, file=sys.stderr) if (task.exitCode() != 0): sys.exit(task.exitCode()) os.chdir(wd) if (recursive): d.foreachDependency(command, True)
def clone(self, branch = None): if (os.path.exists(self.repositoryPath)): return arguments = ['clone', '--recursive'] if (branch != None): arguments += ['--branch', branch] arguments += [self.remoteURL, self.repositoryPath] task = Task('git') task.run(arguments) if (task.exitCode() != 0): raise ValueError(task.output) self.__findGitRoot() self.__findGitDirectory()
def clone(self, branch=None): if (os.path.exists(self.repositoryPath)): return arguments = ['clone', '--recursive'] if (branch != None): arguments += ['--branch', branch] arguments += [self.remoteURL, self.repositoryPath] task = Task('git') task.run(arguments) if (task.exitCode() != 0): raise ValueError(task.output) self.__findGitRoot() self.__findGitDirectory()
def __runGitTask(self, arguments, useConfig=True, exitOnError=True): wd = os.getcwd() if (useConfig): arguments = ['--work-tree=' + self.repositoryPath] + arguments if (self.gitPath != None): arguments = ['--git-dir=' + self.gitPath] + arguments else: os.chdir(self.repositoryPath) # print('zserhardt@zserhardt-iMac:' + os.getcwd() + '$ git ' + ' '.join(arguments)) task = Task('git').run(arguments) if (task.exitCode() != 0 and exitOnError): print(task.output, file=sys.stderr) sys.exit(task.exitCode()) if (not useConfig): os.chdir(wd) return task
def __runGitTask(self, arguments, useConfig = True, exitOnError = True): wd = os.getcwd() if (useConfig): arguments = ['--work-tree=' + self.repositoryPath] + arguments if (self.gitPath != None): arguments = ['--git-dir=' + self.gitPath] + arguments else: os.chdir(self.repositoryPath) # print('zserhardt@zserhardt-iMac:' + os.getcwd() + '$ git ' + ' '.join(arguments)) task = Task('git').run(arguments) if (task.exitCode() != 0 and exitOnError): print(task.output, file=sys.stderr) sys.exit(task.exitCode()) if (not useConfig): os.chdir(wd) return task
def foreachDependency(self, command, recursive = False): if (self.config == None): return runCommand = command if (runCommand.startswith('!sh ')): runCommand = command[4:] i = runCommand.index(' ') task = Task(runCommand[:i]) runCommand = runCommand[i + 1:] else: task = Task('git') for p in self.config.sections(): d = GitDependenciesRepository(self.config[p]['url'], os.path.join(self.repositoryPath, p)) wd = os.getcwd() os.chdir(d.repositoryPath) task.run(runCommand.split(' ')) if (task.output != ''): print(task.output, file=sys.stderr) if (task.exitCode() != 0): sys.exit(task.exitCode()) os.chdir(wd) if (recursive): d.foreachDependency(command, True)
def _shouldUsePools(self): task = Task('which').run(['git-pool']) if (task.exitCode() != 0): return False else: return True