MCPcopy Create free account
hub / github.com/crewAIInc/crewAI / get_github_contributors

Function get_github_contributors

lib/devtools/src/crewai_devtools/cli.py:775–829  ·  view source on GitHub ↗

Get GitHub usernames from commit range using GitHub API. Args: commit_range: Git commit range (e.g., "abc123..HEAD"). repo: GitHub repo in ``owner/name`` form to resolve commits against. cwd: Directory to run git commands in (defaults to current). Returns: L

(
    commit_range: str,
    repo: str = "crewAIInc/crewAI",
    cwd: Path | None = None,
)

Source from the content-addressed store, hash-verified

773
774
775def get_github_contributors(
776 commit_range: str,
777 repo: str = "crewAIInc/crewAI",
778 cwd: Path | None = None,
779) -> list[str]:
780 """Get GitHub usernames from commit range using GitHub API.
781
782 Args:
783 commit_range: Git commit range (e.g., "abc123..HEAD").
784 repo: GitHub repo in ``owner/name`` form to resolve commits against.
785 cwd: Directory to run git commands in (defaults to current).
786
787 Returns:
788 List of GitHub usernames sorted alphabetically.
789 """
790 try:
791 try:
792 gh_token = run_command(["gh", "auth", "token"])
793 except subprocess.CalledProcessError:
794 gh_token = None
795
796 g = Github(login_or_token=gh_token) if gh_token else Github()
797 github_repo = g.get_repo(repo)
798
799 commit_shas = run_command(
800 ["git", "log", commit_range, "--pretty=format:%H"], cwd=cwd
801 ).split("\n")
802
803 contributors = set()
804 for sha in commit_shas:
805 if not sha:
806 continue
807 try:
808 commit = github_repo.get_commit(sha)
809 if commit.author and commit.author.login:
810 contributors.add(commit.author.login)
811
812 if commit.commit.message:
813 for line in commit.commit.message.split("\n"):
814 if line.strip().startswith("Co-authored-by:"):
815 if "<" in line and ">" in line:
816 email_part = line.split("<")[1].split(">")[0]
817 if "@users.noreply.github.com" in email_part:
818 username = email_part.split("+")[-1].split("@")[0]
819 contributors.add(username)
820 except Exception: # noqa: S112
821 continue
822
823 return sorted(list(contributors))
824
825 except Exception as e:
826 console.print(
827 f"[yellow]Warning:[/yellow] Could not fetch GitHub contributors: {e}"
828 )
829 return []
830
831
832def _poll_pr_until_merged(

Callers 1

_generate_release_notesFunction · 0.85

Calls 3

run_commandFunction · 0.70
addMethod · 0.45
printMethod · 0.45

Tested by

no test coverage detected