Skip to content
This repository was archived by the owner on Nov 4, 2022. It is now read-only.

[WIP] Add search feature to repo command #588

Closed
wants to merge 1 commit into from

Conversation

svallory
Copy link
Contributor

Hey there, I constantly search for repos on GH because the org I work for has literally hundreds of them with odd names :/

So I found out about nodegh today (which is awesome btw!) but grepping the result of list was too slow, so I decided to add the search option.

The feature is incomplete, needs docs, but I decided to share sooner so you guys can check and tell me if I'm going in the right direction ;)

Btw, options.user is always set. So for now I had to use a workaround to detect if the user passed it or not here

This will close #451 when it's done

@protoEvangelion
Copy link
Member

@svallory You are headed in the right direction. I will review more in depth soon 😄

It looks like you have already found it but just in case here is the relevant api doc: https://octokit.github.io/rest.js/#api-Search-repos

This is probably the best example of trying to distinguish user from an organization if that's what you are trying to do: https://github.com/node-gh/gh/blob/master/lib/cmds/repo.js#L423

@svallory
Copy link
Contributor Author

@protoEvangelion I saw that code. The problem I found is that options.user is always set to the logged user. So I can't tell if that option was passed to the command by looking at that variable. At least in the context of the search command, if the user option isn't specified, it should be null, so the search won't be restricted. This looks like a bug, but I didn't have time to debug it.

@protoEvangelion
Copy link
Member

Ya I definitely see the problem in conflating argv with ~/.gh.json options.

It looks like we set it early on in the program here: https://github.com/node-gh/gh/blob/master/lib/cmd.js#L152

I think your workaround is fine for now, and we can do a better job in the future of delineating between argv and real options.

@protoEvangelion
Copy link
Member

@svallory I noticed you still had this marked as WIP. Is there anything else you wanted to do for this?

@svallory
Copy link
Contributor Author

svallory commented Jun 7, 2019

Hi @protoEvangelion, sorry for the huuuge delay. There are no tests written and the question about the workaround. But I did use the search function in a script and it worked

@protoEvangelion
Copy link
Member

Will reopen because git will not let me push to your branch even if using -f.

@protoEvangelion
Copy link
Member

#685

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

Successfully merging this pull request may close these issues.

Search repositories
2 participants