import re


def _compose_comment(remote: str, sha: str, git_log: str) -> str:
    """Composes a comment describing the original (triggering) commit.

    Arguments:
        remote {str} -- a link to the remote git repo
        sha {str} -- the hash of the commit
        git_log {str} -- the git log for the commit

    Returns:
        str -- a comment describing the commit
    """
    match = re.match(r"(https://github.com/([^/]+)/([^/.]+).*?)(\.git)?", remote)
    if match:
        link = f"{match.group(1)}/commit/{sha}"
        source_repo = match.expand(r"\2/\3")
        lines = [
            git_log,
            f"Source-Repo: {source_repo}",
            f"Source-Sha: {sha}",
            f"Source-Link: {link}",
        ]
    else:
        lines = [git_log, f"Source-Repo: {remote}", f"Source-Sha: {sha}"]
    return "\n".join(lines)