Skip to content

Add `src repos list|enable|disable` commands

Warren Gifford requested to merge sg/new into master

Created by: slimsag

This PR adds a new top-level command src repos (alias: src repo) with three new subcommands: src repos list, src repos enable and src repos disable.

Examples

For command-specific examples see the help flag (src repos list -h). In this section I'll write examples of how you can combine these for useful effects.

List all repositories that are disabled on Sourcegraph

The following will list all repositories on Sourcegraph that are disabled, while excluding enabled ones:

src repos list -first=-1 -disabled -enabled=false

(add -query='github.com/slimsag/' to match a query string if you only want a subset, or pipe to grep)

Enable all disable repositories on Sourcegraph matching a query string

The following will enable any disabled repository on Sourcegraph whose name matches the query string github.com/slimsag/

src repos list -first=-1 -disabled -enabled=false -query='github.com/slimsag/' | xargs src repos enable

Other notes/changes

  • src repos list takes a variety of arguments, see src repos list -h for info.

    • By default, I've set the -first limit flag to 1000 to avoid doing too much intensive work by default. Many users may want to specify -1 for this if they truly want all repositories.
  • src repos enable and src repos disable take a list of repositories to enable/disable, e.g. src repos enable github.com/my/repo1 github.com/my/repo2. See src repos enable -h for more information.

  • A number of refactors have been. Best review this PR as individual commits.

  • Added support for nested subcommands (like src repos list, whereas before we only had one level deep src api) and command aliases (src repo is an alias for src repos)

  • Added support for other non-src api commands to invoke the GraphQL API (needed for basically everything we'll want to add in the future).

  • Added proper error checking for invalid HTTP responses with non-200 status codes.

  • src api and other commands now emit a separate exit code 2 any time the actual request went through but GraphQL responded with {data: ?, errors: ["some errors"]}. This will let people easily detect GraphQL errors from e.g. bash scripts.

Merge request reports

Loading