Get the year of a commit.
(self, commit_hash: str)
| 271 | return False |
| 272 | |
| 273 | def _get_commit_year(self, commit_hash: str) -> Optional[int]: |
| 274 | """Get the year of a commit.""" |
| 275 | try: |
| 276 | result = subprocess.run( |
| 277 | ["git", "show", "-s", "--format=%ad", "--date=format:%Y", commit_hash], |
| 278 | capture_output=True, |
| 279 | text=True, |
| 280 | cwd=self.repo_root, |
| 281 | ) |
| 282 | |
| 283 | if result.returncode == 0: |
| 284 | return int(result.stdout.strip()) |
| 285 | except (subprocess.SubprocessError, ValueError): |
| 286 | pass |
| 287 | |
| 288 | return None |
| 289 | |
| 290 | def _generate_spdx_headers(self, contributors: Dict[str, Set[int]]) -> List[str]: |
| 291 | """Generate SPDX-FileCopyrightText headers for contributors.""" |