diff --git a/tildewiki/git_wrapper.py b/tildewiki/git_wrapper.py index 13fdba3..869b18c 100644 --- a/tildewiki/git_wrapper.py +++ b/tildewiki/git_wrapper.py @@ -11,6 +11,12 @@ import pygit2 # i want to standardize on gitpython, but gotta figure out the repo status and # 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): # TODO port to GitPython repo = pygit2.clone_repository(to_clone, local_path) diff --git a/tildewiki/main.py b/tildewiki/main.py index 742e084..b84c88d 100644 --- a/tildewiki/main.py +++ b/tildewiki/main.py @@ -179,7 +179,8 @@ def get(config, preview, preview_path, path): help='Path to shared wiki git repository.', type=WikiRepo(**DEFAULT_PATH_KWARGS)) @pass_config 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): compile_wiki(local_repo_path, preview_path)