Skip to main content

tagged_commit

Function tagged_commit 

Source
pub fn tagged_commit(
    root: &Path,
    path: &Path,
    sha: &str,
    read: &dyn Fn(&str) -> Option<String>,
) -> Result<Option<VersionCommit>>
Expand description

sha as the release commit of the version read finds in path at HEAD, when HEAD contains sha and sha carries that version.

A release tag can name a commit other than HEAD and still be that version’s release. Four cases qualify:

  • A publish rerun after later commits tagged a newer HEAD at the same version.
  • A version set again after a revert, which keeps the tag from its first release.
  • A tagged commit that left the first-parent history while HEAD keeps it. A forkctl append publish rewrites a branch and merges it back with its old tip as the second parent. Only that parent then contains the tagged commit. The new first-parent commit at the same version may change other files.
  • A tag on a commit made before the package’s file existed, such as one before the version moved to a VERSION file. The tag’s name renders the version, so that commit is the release.

In every case the registry already has the version, so the tag’s commit is the release. Only the version is compared, never the tree, and a commit with no file at path has no version to compare.

On the first-parent history the depth is the tagged commit’s own. Off it, the depth is that of the oldest first-parent commit that contains the tagged commit, the merge that brought it in. None means the tag is on a commit with another version, or on a commit HEAD does not contain.

§Errors

Returns an error when:

  • root is in no repository;
  • path is outside it;
  • HEAD has no version in path;
  • a commit or tree cannot be read.

It also returns a lookup::Unavailable error when the walk reaches a shallow clone’s boundary before finding sha. It returns an error too when no merge-base can be computed between a first-parent commit and sha.