def list_tag(self): self.init_repo() with self.local.cd(self.dir_codebase_project): command = 'git tag -l' result = self.local.run(command, wenv=self.config()) tags = color_clean(result.stdout.strip()) tags = tags.split('\n') return [color_clean(tag.strip()) for tag in tags] return None
def list_commit(self, branch): self.init_repo() with self.local.cd(self.dir_codebase_project): command = 'git checkout %s && git pull' % (branch) self.local.run(command, wenv=self.config()) command = 'git log -35 --pretty="%h #_# %an #_# %s"' result = self.local.run(command, wenv=self.config()) current_app.logger.info(result.stdout) commit_log = color_clean(result.stdout.strip()) current_app.logger.info(commit_log) commit_list = commit_log.split('\n') commits = [] for commit in commit_list: if not re.search('^.+ #_# .+ #_# .*$', commit): continue commit_dict = commit.split(' #_# ') current_app.logger.info(commit_dict) commits.append({ 'id': commit_dict[0], 'name': commit_dict[1], 'message': commit_dict[2], }) return commits # TODO return None
def list_branch(self): self.init_repo() with self.local.cd(self.dir_codebase_project): command = 'git pull' result = self.local.run(command, wenv=self.config()) if result.exited != Code.Ok: raise WalleError(Code.shell_git_pull_fail) current_app.logger.info(self.dir_codebase_project) command = 'git branch -r' result = self.local.run(command, wenv=self.config()) # if result.exited != Code.Ok: # raise WalleError(Code.shell_run_fail) # TODO 三种可能: false, error, success branches = color_clean(result.stdout.strip()) branches = branches.split('\n') # 去除 origin/HEAD -> 当前指向 # 去除远端前缀 branches = [branch.strip().lstrip('origin/') for branch in branches if not branch.strip().startswith('origin/HEAD')] return branches return None
def list_branch(self): self.init_repo() with self.local.cd(self.dir_codebase_project): command = 'git pull' from flask import current_app from walle.service import utils current_app.logger.info(utils.detailtrace()) result = self.local.run(command, wenv=self.config()) current_app.logger.info(self.dir_codebase_project) command = 'git branch -r' result = self.local.run(command, wenv=self.config()) # TODO 三种可能: false, error, success branches = color_clean(result.stdout.strip()) branches = branches.split('\n') # 去除 origin/HEAD -> 当前指向 # 去除远端前缀 branches = [ branch.strip().lstrip('origin/') for branch in branches if not branch.strip().startswith('origin/HEAD') ] return branches return None
def list_tag(self): self.init_repo() with self.localhost.cd(self.dir_codebase_project): command = 'git tag -l' result = self.localhost.local(command, pty=False, wenv=self.config()) tags = result.stdout.strip() tags = tags.split('\n') return [color_clean(tag.strip()) for tag in tags] return None