MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / _get_commit_year

Method _get_commit_year

scripts/add-spdx-attribution.py:273–288  ·  view source on GitHub ↗

Get the year of a commit.

(self, commit_hash: str)

Source from the content-addressed store, hash-verified

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."""

Callers 1

_analyze_git_blameMethod · 0.95

Calls 1

runMethod · 0.45

Tested by

no test coverage detected