Skip to content
BETAGuardrails are in beta. The library, the configuration format and the CLI command can still change.

Guardrails / git

The change is small enough to review

git/changed-files-budget@v1

The build range changes few enough files that a reviewer can hold the whole change in their head.

Idgit/changed-files-budget
Versionv1
Categorygit
Default severityinfo
Interpreterpython3
Timeout30 seconds
Violations tolerated0
Collectsgit

Collectors

This guardrail gathers nothing itself. It depends on the collectors below, which the CLI runs once per build before any check, and reads what they found out of GUARDRAIL_FACTS. A collector that collects nothing skips this guardrail rather than failing it.

CollectorGathersInputs it is given
gitThe repository, HEAD, the remotes, and every commit between the base ref and HEAD with its message, author, parents and the files the range changed.baseRef

The inputs above are this guardrail's own, passed straight through. Configuring one in buildnote.json changes what is collected, and two guardrails configured the same way share the one collection.

Configuration

json
{
  "guardrails": {
      "failOn": "error",
      "comment": true,
      "checks": [
          {
              "use": "git/changed-files-budget@v1",
              "severity": "info",
              "with": {
                  "baseRef": "origin/main",
                  "maxFiles": "50",
                  "ignore": ""
              },
              "exemptions": []
          }
      ]
  }
}

Inputs

InputDescriptionDefaultEnvironment variable
baseRefRef the range starts at. The commits checked are <baseRef>..HEAD.origin/mainGUARDRAIL_INPUT_BASEREF
maxFilesMost files the range may change.50GUARDRAIL_INPUT_MAXFILES
ignoreComma separated globs excluded from the count, for generated files and lock files a reviewer does not read line by line.``GUARDRAIL_INPUT_IGNORE

How to fix

Split the change. A review that cannot be done properly is a control that exists on paper only, and reviewer attention falls off sharply with size: the approval on a thousand file pull request evidences nothing.

Where a large change is unavoidable — a rename, a generated file, a dependency bump — raise maxFiles for that run rather than removing the guardrail, so the exception is visible.

More in git

  • git/author-identity-domain. Every commit in the build range was authored and committed by an address on a domain the organisation controls.
  • git/conventional-commits. Every commit message in the build range follows the Conventional Commits specification: the subject line, the blank line before the body, and the BREAKING CHANGE footer.
  • git/no-merge-commits. The build range contains no merge commits.
  • git/no-wip-commits. The build range carries no commit that says it was never meant to be merged.
  • git/work-item-reference. Every commit in the build range, or the branch it is on, names the change record it belongs to.

All 6 git guardrails

Buildnote Limited
Registered in England and Wales, Reg: 16140412