ghcontract

package
v0.16.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2026 License: MIT Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ghcontract pins the forge client's `--json` field lists, so a test's fake forge client refuses a field the real one refuses.

The problem it closes: `abcd land` asked `gh pr view --json` for isInMergeQueue, a field gh has no such name for, and a fake forge that answered any field hid it; every real queue confirmation failed. The lists here are gh's own, as `gh pr view --json`, `gh pr list --json` (the same set) and `gh repo view --json` print them with no value, under gh-2.100.0/. Refresh them by running those three commands with a newer gh.

It pins the forge's GraphQL fields the same way (graphql-fields.txt, read by introspection), and CheckGraphQL refuses a query selecting a field its type does not have, so a renamed or mistyped field in a query abcd sends fails a test rather than the real forge.

It is a test-support package, as gittest is: production code never imports it.

Index

Constants

View Source
const Version = "2.100.0"

Version is the gh release the lists were read from.

Variables

This section is empty.

Functions

func Check

func Check(args []string) error

Check refuses a forge client call (gh's arguments) whose `--json` or `--json=` names a field gh does not take for that command, as gh does, and a `--json` on a command whose list is not pinned. A call with no `--json` passes.

func CheckGraphQL

func CheckGraphQL(query string) error

CheckGraphQL refuses a GraphQL query that selects a field its type does not have in the pinned schema, as the forge refuses it. It parses the shape abcd's queries take, and refuses any other: an optional `query` keyword, name and variable definitions, then nested selections of plain fields, each with optional arguments, and inline fragments (`... on Type { }`) on a union the type is pinned to be, or on the selection's own type. An alias, a named fragment, a directive or a mutation is refused as not parsed rather than passed unchecked; arguments are not checked.

func Fields

func Fields(command string) []string

Fields is the `--json` field list gh takes for the command named by the first two arguments ("pr view", "pr list", "repo view"), or nil for a command whose list is not pinned here.

func GraphQLField

func GraphQLField(typ, field string) (string, bool)

GraphQLField reports the named type of field on the forge's GraphQL type typ, and whether the pinned schema has that field.

func RESTField added in v0.16.0

func RESTField(resource, field string) bool

RESTField reports whether the forge's REST resource ("collaborator- permission", "pull-request-review", "pull-request", "workflow-runs", "check-runs") has field, a dotted path for a field inside an object ("user.login"), as the pinned list holds it.

func Shell

func Shell() string

Shell is a POSIX-shell function, ghcontract_check, for a stub forge client written as a script: called with the script's arguments ("$@"), it exits 1 with gh's message on a field Check refuses.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL