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

Function get_github_contributors

lib/devtools/src/crewai_devtools/cli.py:763–817  ·  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

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