MCPcopy Index your code
hub / github.com/Codeplain-ai/codeplain / _get_commit_with_frid

Function _get_commit_with_frid

git_utils.py:298–331  ·  view source on GitHub ↗

Finds commit with given frid mentioned in the commit message. Args: repo (Repo): Git repository object frid (str): functionality ID module_name (Optional[str]): Module name to filter by. If provided, only returns commits that ha

(repo: Repo, frid: str, module_name: Optional[str] = None)

Source from the content-addressed store, hash-verified

296
297
298def _get_commit_with_frid(repo: Repo, frid: str, module_name: Optional[str] = None) -> str:
299 """
300 Finds commit with given frid mentioned in the commit message.
301
302 Args:
303 repo (Repo): Git repository object
304 frid (str): functionality ID
305 module_name (Optional[str]): Module name to filter by. If provided, only returns
306 commits that have both the FRID and module name.
307
308 Returns:
309 str: Commit SHA if found, empty string otherwise
310 """
311 commit_message_pattern = FUNCTIONAL_REQUIREMENT_FINISHED_COMMIT_MESSAGE.format(frid)
312
313 # If no module name filtering is needed, use the original logic
314 if not module_name:
315 return _get_commit_with_message(repo, commit_message_pattern)
316
317 # Use multiple grep patterns with --all-match for AND condition
318 escaped_frid_message = commit_message_pattern.replace("[", "\\[").replace("]", "\\]")
319 module_name_pattern = MODULE_NAME_MESSAGE.format(module_name)
320 escaped_module_message = module_name_pattern.replace("[", "\\[").replace("]", "\\]")
321
322 return repo.git.rev_list(
323 repo.active_branch.name,
324 "--grep",
325 escaped_frid_message,
326 "--grep",
327 escaped_module_message,
328 "--all-match",
329 "-n",
330 "1",
331 )
332
333
334def has_commit_for_frid(repo_path: Union[str, os.PathLike], frid: str, module_name: Optional[str] = None) -> bool:

Callers 2

_get_commitFunction · 0.85
has_commit_for_fridFunction · 0.85

Calls 2

_get_commit_with_messageFunction · 0.85
formatMethod · 0.45

Tested by

no test coverage detected