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