Github Search API - Exclude certain topics
Asked Answered
F

1

12

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

Faenza answered 3/1, 2021 at 19:50 Comment(1)
I think this is a bug in the github search. I confirm this is not working for the topic search.Sclerodermatous
S
1

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
Speciality answered 27/9, 2022 at 9:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.