Creates a new Commit with the given hash. Args: hash: The hexadecimal hash of the commit. message: The one-line summary of the commit. If empty, this method will ask git for the commit message.
(self, hash: str, message: str = "")
| 80 | """A git commit hash and its one-line message.""" |
| 81 | |
| 82 | def __init__(self, hash: str, message: str = ""): |
| 83 | """Creates a new Commit with the given hash. |
| 84 | |
| 85 | Args: |
| 86 | hash: The hexadecimal hash of the commit. |
| 87 | message: The one-line summary of the commit. If empty, this method |
| 88 | will ask git for the commit message. |
| 89 | """ |
| 90 | self.hash = hash.strip() |
| 91 | if not message: |
| 92 | # Ask git for the commit message. |
| 93 | lines = run_git(["log", "-1", "--pretty=%s", self.hash]) |
| 94 | # Should just be one line, but could be zero. |
| 95 | message = " ".join(lines) |
| 96 | self.message = message.strip() |
| 97 | |
| 98 | @staticmethod |
| 99 | def from_line(line: str) -> "Commit": |