Make it possible to generate HTML view for any repository

This commit is contained in:
Marco Castelluccio 2020-02-26 16:06:47 +01:00
Родитель 4eefc02ba6
Коммит 374bf6a0e9
2 изменённых файлов: 18 добавлений и 7 удалений

Просмотреть файл

@ -10,7 +10,14 @@ from microannotate import viewer
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("repository_dir", help="Path to the repository", action="store")
parser.add_argument(
"repository_dir", help="Path to the input repository", action="store"
)
parser.add_argument(
"microannotated_repository_dir",
help="Path to the microannotated repository",
action="store",
)
parser.add_argument(
"path", help="Path to the file in the repository", action="store"
)
@ -19,4 +26,8 @@ if __name__ == "__main__":
)
args = parser.parse_args()
print(viewer.html(args.repository_dir, args.rev, args.path))
print(
viewer.html(
args.repository_dir, args.microannotated_repository_dir, args.rev, args.path
)
)

Просмотреть файл

@ -14,21 +14,21 @@ import pygit2
from microannotate import annotatehelper, utils
def html(repository_dir, rev, path):
repository_dir = os.path.realpath(repository_dir)
def html(repository_dir, microannotated_repository_dir, rev, path):
microannotated_repository_dir = os.path.realpath(microannotated_repository_dir)
repo = pygit2.Repository(repository_dir)
repo = pygit2.Repository(microannotated_repository_dir)
proc = subprocess.run(
["git", "blame", "--porcelain", rev, path],
cwd=repository_dir,
cwd=microannotated_repository_dir,
check=True,
capture_output=True,
)
blame_output = proc.stdout.decode("utf-8")
original_commit_hash = utils.get_original_hash(repo, rev)
os.chdir("/home/marco/Documenti/FD/mozilla-central")
os.chdir(repository_dir)
hg = hglib.open(".")
original_file_content = hg.cat(
[path.encode("ascii")], rev=original_commit_hash.encode("ascii")