Source code for datakit_github.repository

import os
import subprocess


[docs]class Repository:
[docs] @staticmethod def initialized(): return os.path.exists('.git')
[docs] @staticmethod def init(): return subprocess.check_output(['git', 'init'])
[docs] @staticmethod def add(): return subprocess.check_output(['git', 'add', '.'])
[docs] @staticmethod def commit(message): return subprocess.check_output(['git', 'commit', '-m', message])
[docs] @staticmethod def add_remote(repo_url, name='origin'): return subprocess.check_output(['git', 'remote', 'add', name, repo_url])
[docs] @staticmethod def rename_current_branch(new_name): return subprocess.check_output(['git', 'branch', '--move', new_name])
[docs] @staticmethod def push(remote='origin', branch='main'): return subprocess.check_output(['git', 'push', '-u', remote, branch])