Below are examples that search repositories on Sourcegraph.com, our open source code search solution for GitHub and GitLab. You can copy and adapt the following search queries for use on your company’s private instance.
See search query syntax reference.
Recent security-related changes on all branches
type:diff repo:@*refs/heads/ after:"5 days ago" \b(auth[^o][^r]|security\b|cve|password|secure|unsafe|perms|permissions)
Admitted hacks and TODOs in app code
-file:\.(json|md|txt)$ hack|todo|kludge|fixme
New usages of a function
type:diff after:"1 week ago" \.subscribe\( lang:typescript
Recent quality related changes on all branches (customize for your linters)
repo:@*refs/heads/:^master type:diff after:"1 week ago" (eslint-disable)
Recent dependency changes
file:package.json type:diff after:"1 week ago"
Sourcegraph's default literal search mode is line-based and will not match across lines, so regex can be useful when you wish to do so:
repo:^github\.com/Parsely/pykafka$ Not leader for partition
Regex searches are also useful when searching boundaries that are not delimited by code structures:
repo:^github\.com/sourcegraph/sourcegraph$ \bbtn-secondary\b
Use structural search when you want to match code boundaries such as () or {}:
repo:^github\.com/sourcegraph/sourcegraph$ try { :[matched_statements] } catch { :[matched_catch] }