Skip to content

Commit

Permalink
fix: fix github.search_commits
Browse files Browse the repository at this point in the history
  • Loading branch information
phil65 committed Nov 13, 2024
1 parent 7614a38 commit dcfa426
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/githarbor/providers/githubrepository.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,12 +348,21 @@ def search_commits(
path: str | None = None,
max_results: int | None = None,
) -> list[Commit]:
kwargs = {"query": query}
# Build the search query
search_query = f"{query} repo:{self._owner}/{self._name}"
# Add branch qualifier if specified
if branch:
kwargs["ref"] = branch
search_query += f" ref:{branch}"
# Add path qualifier if specified
if path:
kwargs["path"] = path
results = self._repo.search_commits(**kwargs)
search_query += f" path:{path}"
kwargs = {"query": search_query}
# kwargs = {"query": f"{self._owner}/{self._name}+{query}"}
# if branch:
# kwargs["ref"] = branch
# if path:
# kwargs["path"] = path
results = self._gh.search_commits(**kwargs)
commits = list(results[:max_results] if max_results else results)
return [self.get_commit(c.sha) for c in commits]

Expand Down Expand Up @@ -672,6 +681,8 @@ def get_recent_activity(

if __name__ == "__main__":
repo = GitHubRepository.from_url("https://github.com/phil65/mknodes")
print(repo.list_workflows())
commits = repo.search_commits("implement")
print(commits)
# print(repo.list_workflows())
branch = repo.get_branch("main")
print(branch)

0 comments on commit dcfa426

Please sign in to comment.