Commit changes with CPython author. Args: name: Module name (e.g., "dataclasses") lib_path: Path to library file/directory (or None) test_paths: Path(s) to test file/directory (or None) cpython_dir: Path to cpython directory hard_deps: Path(s) to hard dep
(
name: str,
lib_path: pathlib.Path | None,
test_paths: list[pathlib.Path] | pathlib.Path | None,
cpython_dir: pathlib.Path,
hard_deps: list[pathlib.Path] | None = None,
verbose: bool = True,
)
| 199 | |
| 200 | |
| 201 | def git_commit( |
| 202 | name: str, |
| 203 | lib_path: pathlib.Path | None, |
| 204 | test_paths: list[pathlib.Path] | pathlib.Path | None, |
| 205 | cpython_dir: pathlib.Path, |
| 206 | hard_deps: list[pathlib.Path] | None = None, |
| 207 | verbose: bool = True, |
| 208 | ) -> bool: |
| 209 | """Commit changes with CPython author. |
| 210 | |
| 211 | Args: |
| 212 | name: Module name (e.g., "dataclasses") |
| 213 | lib_path: Path to library file/directory (or None) |
| 214 | test_paths: Path(s) to test file/directory (or None) |
| 215 | cpython_dir: Path to cpython directory |
| 216 | hard_deps: Path(s) to hard dependency files (or None) |
| 217 | verbose: Print progress messages |
| 218 | |
| 219 | Returns: |
| 220 | True if commit was created, False otherwise |
| 221 | """ |
| 222 | import subprocess |
| 223 | |
| 224 | # Normalize test_paths to list |
| 225 | if test_paths is None: |
| 226 | test_paths = [] |
| 227 | elif isinstance(test_paths, pathlib.Path): |
| 228 | test_paths = [test_paths] |
| 229 | |
| 230 | # Normalize hard_deps to list |
| 231 | if hard_deps is None: |
| 232 | hard_deps = [] |
| 233 | |
| 234 | # Stage changes |
| 235 | paths_to_add = [] |
| 236 | if lib_path and lib_path.exists(): |
| 237 | paths_to_add.append(str(lib_path)) |
| 238 | for test_path in test_paths: |
| 239 | if test_path and test_path.exists(): |
| 240 | paths_to_add.append(str(test_path)) |
| 241 | for dep_path in hard_deps: |
| 242 | if dep_path and dep_path.exists(): |
| 243 | paths_to_add.append(str(dep_path)) |
| 244 | |
| 245 | if not paths_to_add: |
| 246 | return False |
| 247 | |
| 248 | version = get_cpython_version(cpython_dir) |
| 249 | subprocess.run(["git", "add"] + paths_to_add, check=True) |
| 250 | |
| 251 | # Check if there are staged changes |
| 252 | result = subprocess.run( |
| 253 | ["git", "diff", "--cached", "--quiet"], |
| 254 | capture_output=True, |
| 255 | ) |
| 256 | if result.returncode == 0: |
| 257 | if verbose: |
| 258 | print("No changes to commit") |