implement reset

master
nathaniel smith 2017-09-24 23:42:26 -07:00
parent 75d8495be8
commit e23db672e2
2 changed files with 8 additions and 1 deletions

View File

@ -11,6 +11,12 @@ import pygit2
# i want to standardize on gitpython, but gotta figure out the repo status and # i want to standardize on gitpython, but gotta figure out the repo status and
# also do the cloning # also do the cloning
def reset_from_origin(repo_path:str) -> None:
repo = gitpython.Repo(repo_path)
repo.remotes['origin'].fetch()
repo.git.reset('--hard', 'origin/master')
def create_repo(to_clone, local_path, author_name, author_email): def create_repo(to_clone, local_path, author_name, author_email):
# TODO port to GitPython # TODO port to GitPython
repo = pygit2.clone_repository(to_clone, local_path) repo = pygit2.clone_repository(to_clone, local_path)

View File

@ -179,7 +179,8 @@ def get(config, preview, preview_path, path):
help='Path to shared wiki git repository.', type=WikiRepo(**DEFAULT_PATH_KWARGS)) help='Path to shared wiki git repository.', type=WikiRepo(**DEFAULT_PATH_KWARGS))
@pass_config @pass_config
def reset(config, local_repo_path): def reset(config, local_repo_path):
raise NotImplementedError() click.confirm("This will overwrite any changes you've made locally. Proceed?", abort=True)
git.reset_from_origin(local_repo_path)
def _preview(preview_path, local_repo_path): def _preview(preview_path, local_repo_path):
compile_wiki(local_repo_path, preview_path) compile_wiki(local_repo_path, preview_path)