Skip to content

feat: GitHub Search #173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Conversation

soar
Copy link

@soar soar commented Jun 18, 2025

Description

Add GitHub Search API to filter repositories before processing

The repository scope can be narrowed down by using the GitHub Search API. This allows you to select repositories based on various criteria, such as language, topics, or other metadata or file content.

If both, --github-repository-search and --github-code-search are provided, the repositories will be filtered by both criteria.

git-xargs \
  --github-org <your-github-org> \
  --github-repository-search "is:private language:go" \
  --github-code-search "filename:Dockerfile ubuntu" \
  "$(pwd)/scripts/update-copyright-year.sh"

TODOs

Read the Gruntwork contribution guidelines.

  • Update the docs.
  • Run the relevant tests successfully, including pre-commit checks.
  • Ensure any 3rd party code adheres with our license policy or delete this line if its not applicable.
  • Include release notes. If this PR is backward incompatible, include a migration guide.

Release Notes (draft)

Added GitHub Search API

Migration Guide

@soar
Copy link
Author

soar commented Jun 21, 2025

@eric-Grunt @Resonance1584 Hello! Found you as reviewers in recent PRs. Do you know whom I can ask to review this?

Copy link

@Resonance1584 Resonance1584 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @soar - thanks for your contributions. This looks good overall, please respond to my questions inline in the review to see if we can reduce some duplicated logic.
Please also take a look at select-repos_test.go and see if you can add some test logic to validate the new select logic.

@@ -131,3 +132,310 @@ func getReposByOrg(config *config.GitXargsConfig) ([]*github.Repository, error)

return allRepos, nil
}

// getReposBySearch uses GitHub's search API to find repositories matching the given query
func getReposBySearch(config *config.GitXargsConfig) ([]*github.Repository, error) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we eliminate this function and call getReposByIntersection etc directly from select-repos?

@@ -200,6 +242,51 @@ func OperateOnRepos(config *config.GitXargsConfig) error {

switch repoSelection.GetCriteria() {

case GithubRepositorySearch:
// If githubRepositorySearch is set, use the GitHub Search API to find matching repositories
reposFetchedFromSearch, err := getReposBySearch(config)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above - can we call getReposByRepositorySearch directly?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants