Fetch latest updates from the remote.
(self)
| 52 | return False |
| 53 | |
| 54 | def fetch(self) -> None: |
| 55 | """Fetch latest updates from the remote.""" |
| 56 | command = ["git", "fetch"] |
| 57 | result = subprocess.run( # noqa: S603 |
| 58 | command, |
| 59 | cwd=self.path, |
| 60 | capture_output=True, |
| 61 | text=True, |
| 62 | ) |
| 63 | if result.returncode == 0: |
| 64 | return |
| 65 | if "No remote repository specified" in result.stderr: |
| 66 | return |
| 67 | details = result.stderr.strip() or result.stdout.strip() or "no output" |
| 68 | raise ValueError( |
| 69 | f"Git fetch failed with exit code {result.returncode} " |
| 70 | f"for command {command!r}: {details}" |
| 71 | ) |
| 72 | |
| 73 | @classmethod |
| 74 | def initialize(cls, path: str = ".") -> Repository: |