sourcegraph/dev/depgraph
Erik Seliger 9fab1b4e1d
depgraph: Fix spurious error when no subcommand name is passed (#61871)
This confused me:

```
terminal command () doesn't define an Exec function
```

Now it prints a help text.

Test plan:

Verified the above behavior by hand.
2024-04-15 16:10:44 +02:00
..
internal remove more remannts of OSS build (#58253) 2023-11-10 07:59:03 +00:00
.gitignore dev: Add depgraph utility (#18883) 2021-03-04 23:49:55 +00:00
BUILD.bazel bazel: introduce build files for Go (#46770) 2023-01-23 14:00:01 +01:00
CODENOTIFY codenotify: dr. fritz is kil (#57313) 2023-10-03 16:19:55 +00:00
lint.go Housekeeping: Add package name aliases to avoid collisions with variables (#47180) 2023-01-31 16:28:57 +01:00
main.go depgraph: Fix spurious error when no subcommand name is passed (#61871) 2024-04-15 16:10:44 +02:00
README.md remove more remannts of OSS build (#58253) 2023-11-10 07:59:03 +00:00
root.go dev/depgraph: add summary -deps.sum -deps.only for detecting binary changes (#35379) 2022-05-19 22:46:10 +00:00
summary.go Housekeeping: Add package name aliases to avoid collisions with variables (#47180) 2023-01-31 16:28:57 +01:00
trace_internal.go Housekeeping: Add package name aliases to avoid collisions with variables (#47180) 2023-01-31 16:28:57 +01:00
trace.go Replace all traditional for-loops (#60988) 2024-03-11 16:05:47 +02:00

Sourcegraph dependency graph development utilities

A development utility specific to Sourcegraph package import conventions.

Building

Run go build in this directory.

Running

Run depgraph {subcommand} somewhere inside the sourcegraph/sourcegraph repository. This will analyze the Sourcegraph package dependency graph then perform some subcommand-specific action over it.

Commands

The following commands are available. Across different commands, {package} should be specified as a relative path without any leading ./. For example, ./dev/depgraph/depgraph summary internal/repos from the root of the sourcegraph directory should work.

summary

Usage: ./dev/depgraph/depgraph summary {package}

This command outputs dependency and dependent information for a particular package.

trace

Usage: ./dev/depgraph/depgraph trace {package} [-dependency-max-depth=1] [-dependent-max-depth=1]

This command outputs a dot-formatted graph encoding the (transitive) dependencies of dependencies and (transitive) dependents of dependents rooted at the given package. Saved to a file trace.dot, you can convert this to SVG (or another format) via dot -Tsvg trace.dot -o trace.svg.

trace-internal

Usage: `./dev/depgraph/depgraph trace-internal {package}

This command outputs a dot-formatted graph encoding the internal dependencies within the given package. Saved to a file trace.dot, you can convert this to SVG (or another format) via dot -Tsvg trace.dot -o trace.svg.

lint

Usage: ./dev/depgraph/depgraph lint [pass...]

This command ensures the following lint passes. Violations of the lint rules will be displayed on standard out, but the utility does not currently exit with a non-zero status.

  • NoBinarySpecificSharedCode: Report shared packages that are imported only by a single command
  • NoDeadPackages: Report unused packages (except for library code and main packages)
  • NoLooseCommands: Report main packages outside of known command roots
  • NoReachingIntoCommands: Report packages that import code from an unrelated command
  • NoUnusedSharedCommandCode: Report packages that could be moved into an internal package