rqm affected

rqm affected turns a list of changed paths into the requirements that the change touches. It reads the requirement files and the sources and runs nothing.

rqm affected [PATH]...

A path is relative to the directory that holds rqm.yaml, not to the directory you run the command in. rqm never runs git; give it the paths that your forge or your version control already printed:

git diff --name-only origin/main...HEAD | rqm affected

Without a path, it reads one path per line from standard input, and blank lines are ignored. With paths as arguments it does not read standard input.

A requirement is affected when its own file is among the paths, or when a changed file declares a test that the requirement claims by an #[rqm("...")] marker or by a selector in its tests list. Each test reason names the test and the line of its declaration. Binding tests to requirements explains the two ways.

rqm.yaml is special: when it is among the paths, every gated requirement is affected, because a policy change can change every outcome. A gated requirement has the test method and is approved or required.

$ rqm affected src/lib.rs
RQM-1  Users can sign in
  test              src/lib.rs:36  sessions::tests::sign_in_with_a_valid_password
  test              src/lib.rs:42  sessions::tests::sign_in_with_a_wrong_password
1 requirements affected by 1 paths

The order and the repetition of the paths do not change the output. A path that cannot be inside the project, such as an absolute path or one that starts with .., is skipped with W-AFFECTED-PATH-IGNORED, and --strict makes that warning fail the command.

Options

$ rqm affected --help
List the requirements that a set of changed paths touches

Usage: rqm affected [OPTIONS] [PATH]...

Arguments:
  [PATH]...  Changed paths, relative to the directory of rqm.yaml. Without any, one path per line is read from standard input

Options:
      --format <FORMAT>  Output format. JSON is the stable contract [default: human] [possible values: human, json]
      --strict           Treat warnings as errors for the exit code. The output itself does not change
  -h, --help             Print help

The data of --format json is described in The JSON output.