def checkout_2_commit(self, branch, commit): ''' @todo 未完成 @param branch: @param commit: @return: ''' PyRepo(self.path).git.checkout(branch) # PyRepo(self.path).head.set_reference(branch) # 方法有问题,只是做了reset,没有checkout PyRepo(self.path).head.set_commit(commit)
def checkout_2_tag(self, tag): ''' 切换到tag @param tag: @return: ''' PyRepo(self.path).git.checkout(tag)
def checkout_2_branch(self, branch): ''' 切换到某个分支 @param branch: @return: ''' PyRepo(self.path).git.checkout(branch)
def tags(self): ''' 获取所有tag,按时间倒序 @param branch: @param kwargs: @return: ''' return [str(tag) for tag in PyRepo(self.path).tags][-10:]
def checkout_2_commit(self, branch, commit): ''' 切换分支的某个commit @param branch: @param commit: @return: ''' self.checkout_2_branch(branch=branch) PyRepo(self.path).git.reset('--hard', commit)
def pull(self): ''' 更新项目 @param branch: @param kwargs: @return: ''' repo = PyRepo(self.path) return repo.remote().pull()
def branches(self): ''' 获取所有分支 @param branch: @param kwargs: @return: ''' # 去除 origin/HEAD -> 当前指向 # 去除远端前缀 branches = PyRepo(self.path).remote().refs # fixbug https://github.com/meolu/walle-web/issues/705 return [str(branch).strip().lstrip('origin').lstrip('/') for branch in branches if not str(branch).strip().startswith('origin/HEAD')]
def checkout_2_tag(self, tag): PyRepo(self.path).git.checkout(tag)
def checkout_2_branch(self, branch): PyRepo(self.path).git.checkout(branch)
def checkout_2_commit(self, branch, commit): PyRepo(self.path).head.set_reference(branch) PyRepo(self.path).head.set_commit(commit)