global_dashboard_as_code/repoConfig.py

20 lines
587 B
Python

#Library includes funtions for interacting with git repos
from git import Repo
import os
#Clones repo if not exists
def clone_repo_if_notexist(repourl, reponame):
if(not os.path.isdir(reponame)):
repo = Repo.clone_from(repourl, reponame)
return repo
return Repo(reponame)
#Performs pull on existing repo
def pull_repo(repo):
origin = repo.remotes.origin
origin.pull()
#Performs add, commit and push on existing repo
def push_repo(repo, message):
repo.git.add(all=True)
repo.index.commit(message)
origin = repo.remotes.origin
origin.push()