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

Nfff3
  • 321
  • 8
  • 24
  • 4
    I think this is a bug in the github search. I confirm this is not working for the topic search. – Vincent Jan 12 '21 at 10:39

1 Answers1

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
TWiStErRob
  • 44,762
  • 26
  • 170
  • 254