Skip to main content

Crate nerdbank_gitversioning

Crate nerdbank_gitversioning 

Source
Expand description

Git-based semantic version calculation compatible with Nerdbank.GitVersioning.

This crate computes deterministic versions from version.json or version.txt files and Git history. It intentionally does not provide MSBuild integration. It supports current stable Rust on Windows, Linux, and macOS.

§Example

use nerdbank_gitversioning::{GitContext, GitEngine, VersionOracle};

fn main() -> Result<(), nerdbank_gitversioning::Error> {
    let context = GitContext::create(".", None, GitEngine::ReadOnly)?;
    let version = VersionOracle::new(&context, None)?.sem_ver2();
    println!("{version}");
    Ok(())
}

Modules§

cloud
Cloud-build provider discovery and common functionality.
cloud_build_services
Implementations for supported cloud-build services.

Structs§

AssemblyVersionOptions
Details of how an assembly version is calculated.
CloudBuildNumberCommitIdOptions
Describes when and where commit information appears in a cloud build number.
CloudBuildNumberOptions
Settings for overriding a cloud build number with version information.
CloudBuildOptions
Options applicable specifically to cloud builds.
CloudCommand
Applies calculated version values to a cloud-build provider.
CloudCommandException
An error from CloudCommand.
CloudCommandOptions
Arguments accepted by CloudCommand::set_build_variables.
CommitDates
The author and committer timestamps for a commit.
FilterPath
A filter (include or exclude) representing a repository-relative path.
GitContext
Represents a directory and selected commit within a Git repository.
NuGetPackageVersionOptions
Settings controlling generated NuGet package versions.
PrepareReleaseOptions
Options controlling one release preparation operation.
PreparedRelease
The complete result of a release preparation operation.
ReleaseBranchInfo
Information about a branch created or updated during release preparation.
ReleaseInfo
Information about the branches affected by release preparation.
ReleaseManager
Creates or advances release branches and updates their version files.
ReleaseOptions
Settings for the prepare-release and tag commands.
ReleasePreparationException
A release preparation failure with a stable classification and useful detail.
SemanticVersion
Describes a numeric version with optional prerelease and build metadata.
Version
A two-, three-, or four-part numeric version.
VersionFile
Reads and writes version files for a Git context.
VersionFileLocations
Absolute locations discovered while resolving version files.
VersionFileRequirements
Controls which version file is returned and whether inheritance is merged.
VersionHeightCalculation
A version height and the commit that most recently contributed to it.
VersionOptions
Describes the versions and policies used by a build.
VersionOracle
The complete set of version values calculated for a project.

Enums§

CloudBuildNumberCommitWhen
The conditions under which a commit ID is included in a cloud build number.
CloudBuildNumberCommitWhere
The position at which a commit ID appears in a cloud build number.
CloudCommandError
The classified failures produced by CloudCommand.
Error
An error produced while reading a repository or calculating a version.
GitContextKind
Describes what kind of context was created.
GitEngine
Selects how repository operations are performed.
ReleaseManagerOutputMode
Selects the rendered output format.
ReleasePreparationError
Classifies failures that can occur while preparing a release.
ReleaseVersionIncrement
The component incremented after creating a release branch.
VersionPosition
Identifies positions in a semantic version.
VersionPrecision
The last component to control in a four-integer version.

Constants§

MAXIMUM_VERSION_COMPONENT
The largest build or revision value accepted by the CLR and Windows version resources.
VERSION_JSON_FILE_NAME
The JSON version filename.
VERSION_SCHEMA
The JSON schema shipped with this crate.
VERSION_TXT_FILE_NAME
The legacy version filename.

Functions§

calculate_version_height
Applies working-copy reset rules before calculating committed version height.
effective_git_engine
Gets the effective Git engine after applying NBGV_GitEngine, Dependabot, and GitHub Copilot policy.
encode_version
Encodes version height and commit identity in a four-component numeric version.
format_release_branch_name
Formats the configured release branch name using the numeric current version.
format_release_tag_name
Formats a release tag template using a semantic version.
get_commit_from_version
Finds the unique reachable commit that could have produced version.
get_commits_from_version
Finds all commits reachable from named references that could have produced version.
get_height
Calculates the longest single ancestry path, including the selected commit.
get_id_as_version
Selects committed or working options and encodes a completed height calculation.
get_version_height
Calculates version height at the selected commit.
truncated_commit_id
Returns the first two object-ID bytes interpreted in network byte order.

Type Aliases§

ReleasePreparationResult
A result returned by release preparation.
Result
A result returned by this crate.