Skip to content
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

feat: use code search to select repositories #399

Merged
merged 5 commits into from
Nov 9, 2023

Conversation

jamestelfer
Copy link
Contributor

@jamestelfer jamestelfer commented Oct 25, 2023

What does this change

Using the --code-search option, it is possible to supply a GitHub code search query that is used to generate the set of repositories to process.

This feature is GItHub-only at the moment.

One caveat to be aware of is that the GitHub API does not yet support queries using the more recent (and much more capable) code search engine. We need to be clear which documentation to use for the search syntax.

Documentation:

What issue does it fix

Closes #401

See also:

Notes for the reviewer

Checklist

  • Made sure the PR follows the CONTRIBUTING.md guidelines
  • Tests if something new is added

(GitHub only) Introduces the `--code-search` flag that allows the
provision of GitHub Code Search terms (legacy) to define the selection
of repositories to be visited.

The repository list will be the unique set of repositories referenced in
the code search results.
@jamestelfer
Copy link
Contributor Author

@lindell this should now be ready for review, all feedback (including "I don't want this") is welcome.

Copy link
Owner

@lindell lindell left a comment

Choose a reason for hiding this comment

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

Almost LGTM, just some minor style comments.

I think this will provide value 👍

cmd/platform.go Outdated Show resolved Hide resolved
internal/scm/github/github.go Outdated Show resolved Hide resolved
internal/scm/github/github.go Outdated Show resolved Hide resolved
internal/scm/github/github.go Show resolved Hide resolved
internal/scm/github/util.go Outdated Show resolved Hide resolved
cmd/platform.go Outdated Show resolved Hide resolved
Use this from the x/exp package instead of a handrolled version.

It's likely that this package will roll into later versions of Go
in a very similar form, allowing for a smooth transition.
@jamestelfer jamestelfer force-pushed the add-code-search branch 2 times, most recently from 75931ee to fd950f2 Compare November 9, 2023 11:20
@jamestelfer
Copy link
Contributor Author

I followed up on the use of map.Values as suggested, but rebased instead of merging sorry, which has messed up the review. I tried to push the original back and merge instead to fix the review pointers, but it seems like that didn't work 😬

Hopefully the changes are small enough to make sense though.

I think I've followed up on all the requested feedback, with #414 raised to follow up on one point. Let me know if there's anything further you'd like me to look at!

Copy link
Owner

@lindell lindell left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Thanks for the contribution 😄

@@ -28,7 +28,8 @@ func configurePlatform(cmd *cobra.Command) {
flags.StringSliceP("group", "G", nil, "The name of a GitLab organization. All repositories in that group will be used.")
flags.StringSliceP("user", "U", nil, "The name of a user. All repositories owned by that user will be used.")
flags.StringSliceP("repo", "R", nil, "The name, including owner of a GitHub repository in the format \"ownerName/repoName\".")
flags.StringP("repo-search", "", "", "Use a repository search to find repositories to target (GitHub only). Forks are NOT included by default, use `fork:true` to include them. See the GitHub documentation for full syntax: https://docs.github.com/en/search-github/searching-on-github/searching-for-repositories")
flags.StringP("repo-search", "", "", "Use a repository search to find repositories to target (GitHub only). Forks are NOT included by default, use `fork:true` to include them. See the GitHub documentation for full syntax: https://docs.github.com/en/search-github/searching-on-github/searching-for-repositories.")
flags.StringP("code-search", "", "", "Use a code search to find a set of repositories to target (GitHub only). Repeated results from a given repository will be ignored, forks are NOT included by default (use `fork:true` to include them). See the GitHub documentation for full syntax: https://docs.github.com/en/search-github/searching-on-github/searching-code.")
Copy link
Owner

Choose a reason for hiding this comment

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

Repeated results from a given repository will be ignored, forks are NOT included by default
This is technically true for all results, but I think it might still be good to add for this one.

@lindell lindell merged commit d8b75f4 into lindell:master Nov 9, 2023
8 checks passed
Copy link
Contributor

github-actions bot commented Nov 9, 2023

Included in release v0.49.0 🎉

@jamestelfer jamestelfer deleted the add-code-search branch November 9, 2023 21:48
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.

Use code search as input for target repository list
2 participants