Skip to content

JSON output

With --json, diffract writes the result to stdout as one JSON object. The Python method DiffractResult.to_dict() gives the same object.

diffract v1.2.0 HEAD --json
{
  "group": "feat!",
  "possible_types": [
    "feat!"
  ],
  "summary": "Breaking change. Removed public names: sheridan.diffract: OldHelper",
  "base_ref": "v1.2.0",
  "head_ref": "HEAD",
  "diff": {
    "added": [],
    "removed": [
      {
        "module": "sheridan.diffract",
        "name": "OldHelper"
      }
    ],
    "changed": []
  }
}

Keys

Key Type Description
group string The group of possible types: feat!, feat, code, test or other. Read Getting started.
possible_types list The Conventional Commit types in the group, for example ["fix", "refactor", "perf", "style", "docs"] for code.
summary string A description of the change for people. Do not parse it.
base_ref string The earlier ref, as you gave it.
head_ref string The later ref, as you gave it. For the staging area, the value is :staged.
diff.added list The added public names. Each item has the keys module and name. A class member has the class name in front of it, for example ApiDiff.changed.
diff.removed list The removed public names. Each item has the keys module and name.
diff.changed list The changes to the public names that are at the two refs. Each item has the keys module, name, detail (a description of the change) and breaking (true or false). Read API changes.

Exit code

--json does not change the exit code. To get an exit code for the type of change, add --exit-code. Read CLI and exit codes.

Read the output in a script

group=$(diffract --json | jq -r .group)