Skip to main content

inspect

Compares one module's pinned commit against the versions its repository has.

inspect(submodule: Submodule, options?: { fetch?: boolean }): SubmoduleState

This is what sync prints.

const state = inspect(module, { fetch: false })
// { current: 'v1.0.0', available: ['v2.0.0', 'v1.1.0', 'v1.0.1'],
//   upgrades: { patch: 'v1.0.1', minor: 'v1.1.0', major: 'v2.0.0' }, … }

Returns

Field
headthe commit checked out right now, which a bump changes
currentthe version pinned, when a tag names it
exactwhether that tag is the commit rather than an ancestor of it
availablenewer version tags, newest first
upgradesthe newest upgrade of each kind
untaggedcommits on the tracked branch no version tag covers
dirtyuncommitted changes, which make moving the pin unsafe
fetchedwhether the remote was reachable, when a fetch was attempted

current falls back to the newest tag the pinned commit descends from, and exact says which of the two you got.

Only tags that parse as semver count. untagged counts what is past them but never becomes an upgrade: a commit makes no statement about what changed.

Fetching

Fetches by default, so the comparison is against what the remote has. Pass { fetch: false } offline or in a shallow CI clone; fetched then comes back undefined rather than false, since nothing was attempted.

An unreachable remote sets fetched to false and is not an error.