diff --git a/config.json.dist b/config.json.dist index 1654b87..3932af5 100644 --- a/config.json.dist +++ b/config.json.dist @@ -4,5 +4,15 @@ "exclude_repositories": [ "repository_name", "other_repository_name" - ] + ], + "aliases": { + "John Doe": [ + "John Doe", + "johndoe" + ], + "Jane Doe": [ + "Jane Doe", + "janedoe" + ] + } } \ No newline at end of file diff --git a/gource_org.py b/gource_org.py index c05ca64..a217691 100644 --- a/gource_org.py +++ b/gource_org.py @@ -5,6 +5,11 @@ import requests from git import Repo config = json.load(open("config.json")) +aliases = { + source_name: target_name + for target_name, source_names in config["aliases"].items() + for source_name in source_names +} def list_repositories(organization_name: str) -> list: @@ -50,9 +55,10 @@ def combine_gource_logs(logs_dir: Path, dst: Path = Path("./gource.log")) -> Non for log_file in logs_dir.iterdir(): with open(log_file) as f: for line in f: - parts = line.split("|") - edited_file_path = f"{log_file.name[:-len('.log')]}{parts[-1]}" - log_line = "|".join(parts[:-1] + [edited_file_path]) + timestamp, author, edit, path = line.split("|") + edited_file_path = f"{log_file.name[:-len('.log')]}{path}" + edited_author = aliases.get(author, author) + log_line = "|".join([timestamp, edited_author, edit, edited_file_path]) logs.append(log_line) dst.write_text("".join(sorted(logs)))