Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Github Search API - Exclude certain topics

According to the docs, I could use - to exclude certain things from the search API... I tested it and this works on the language field for example, but doesn't work on topics.
According to the documentation:

note cats stars:>10 -language:javascript matches repositories with the word "cats" that have more than 10 stars but are not written in JavaScript.

But if I want to search for cats stars:>10 -topic:javascript it doesn't work anymore, although I tested it and there are exactly 9 repositories that have javascript as a topic.
So

cats stars:>10 returns 714 results

cats stars:>10 -topic:javascript returns 714 results (- doesn't work)
cats stars:>10 +topic:javascript returns 9 results

cats stars:>10 -language:javascript returns 602 results (- works as expected)
cats stars:>10 +language:javascript returns 112 results

like image 875
Nfff3 Avatar asked Jan 03 '21 19:01

Nfff3


1 Answers

There's a workaround with GitHub CLI:

Replace: ORG with organization name.

Unix:

gh repo list ORG --json name,repositoryTopics --limit 200 --jq '.[] | select(.repositoryTopics//[] | all(.name != "unwanted-label-name"))' | sort

Windows:

gh repo list ORG --json name,repositoryTopics --limit 200 --jq ".[] | select(.repositoryTopics//[] | all(.name != """unwanted-label-name"""))" | sort

For GitHub enterprise, set environment variable before running commands:

GH_HOST=your.github.enterprise.company.host
like image 57
TWiStErRob Avatar answered Jan 02 '23 10:01

TWiStErRob