MCPcopy Create free account
hub / github.com/BillHuang2001/evogit / lint_code_base

Function lint_code_base

python-impl/evogit/api.py:632–680  ·  view source on GitHub ↗

Lint the code base. The result will be written to the git notes as well as returning it.

(
    config: EvoGitConfig,
    commits: list[str],
    worktrees: Optional[list[str]] = None,
    overwrite: bool = False,
)

Source from the content-addressed store, hash-verified

630
631
632def lint_code_base(
633 config: EvoGitConfig,
634 commits: list[str],
635 worktrees: Optional[list[str]] = None,
636 overwrite: bool = False,
637) -> list[str]:
638 """Lint the code base.
639 The result will be written to the git notes as well as returning it.
640 """
641 provided_worktrees = worktrees is not None
642 if not provided_worktrees:
643 worktrees = prepare_temp_worktrees(config, commits)
644
645 # get the lint feedback, the handler is a subprocess.Popen object
646 handlers = []
647 for worktree in worktrees:
648 handlers.append(
649 get_linter_feedback(
650 worktree, project_type=config.project_type, async_run=True
651 )
652 )
653
654 results = []
655 # wait for these subprocess to end, and get the text output
656 for handler in handlers:
657 # wait for the process to finish
658 try:
659 stdout, stderr = handler.communicate(timeout=120)
660 results.append(stdout)
661 except subprocess.TimeoutExpired:
662 handler.kill()
663 stdout, stderr = handler.communicate()
664 logger.warning(f"Linting timed out: {stderr}")
665 results.append(stdout)
666
667 # write the results to the git notes
668 for commit, result in zip(commits, results):
669 try:
670 git.add_note(config, commit, result, overwrite=overwrite)
671 except Exception as e:
672 # if overwrite is False, and the note already exists, ignore the error
673 # if overwrite is True, log the error
674 if overwrite:
675 logger.error(f"Failed to write note for commit {commit}: {e}")
676
677 if not provided_worktrees:
678 cleanup_temp_worktrees(config)
679
680 return results

Callers

nothing calls this directly

Calls 3

prepare_temp_worktreesFunction · 0.85
get_linter_feedbackFunction · 0.85
cleanup_temp_worktreesFunction · 0.70

Tested by

no test coverage detected