tilde-wiki/tildewiki/git_service.py

28 lines
855 B
Python

import pygit2
def create_repo(to_clone, local_path, author_name, author_email):
repo = pygit2.clone_repository(to_clone, local_path)
repo.config['user.name'] = author_name
repo.config['user.email'] = author_email
def make_commit(repo_path, author_name, author_email):
"""Given a path to a repository, adds everything and commits it."""
repo = pygit2.Repository(repo_path)
repo.index.add_all()
repo.index.write()
tree = repo.index.write_tree()
author = pygit2.Signature(author_name, author_email)
committer = pygit2.Signature(author_name, author_email)
oid = repo.create_commit(
'refs/head/master',
author,
committer,
'wiki update'.format(author_name),
tree,
[repo.head.get_object().hex])
repo.reset(oid, pygit2.GIT_RESET_HARD)
# TODO push wrapper
# TODO