Creates a Commit from a string of the form ' [ ]'.
(line: str)
| 97 | |
| 98 | @staticmethod |
| 99 | def from_line(line: str) -> "Commit": |
| 100 | """Creates a Commit from a string of the form '<hash> [<message>]'.""" |
| 101 | parts = line.split(" ", maxsplit=1) |
| 102 | parts = [part.strip() for part in parts if part.strip()] |
| 103 | assert len(parts) >= 1, f"Expected at least one part in line '{line}'" |
| 104 | return Commit(hash=parts[0], message=parts[1] if len(parts) > 1 else "") |
| 105 | |
| 106 | def __repr__(self): |
| 107 | return f"Commit('{self.hash[:8]}', '{self.message}')" |