21 lines
419 B
Python
21 lines
419 B
Python
|
from git import Repo
|
||
|
import os
|
||
|
|
||
|
|
||
|
def getBranch():
|
||
|
repo = Repo(os.getcwd())
|
||
|
branch = repo.active_branch
|
||
|
return branch.name
|
||
|
|
||
|
|
||
|
def setBranch(branch):
|
||
|
repo = Repo(os.getcwd())
|
||
|
git = repo.git
|
||
|
git.switch(branch)
|
||
|
|
||
|
def getBranchList():
|
||
|
repo = Repo(os.getcwd())
|
||
|
remote_refs = repo.remote().refs
|
||
|
refs = list(ref.remote_head for ref in remote_refs if ref.remote_head != 'HEAD')
|
||
|
return refs
|