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§
- Assembly
Version Options - Details of how an assembly version is calculated.
- Cloud
Build Number Commit IdOptions - Describes when and where commit information appears in a cloud build number.
- Cloud
Build Number Options - Settings for overriding a cloud build number with version information.
- Cloud
Build Options - Options applicable specifically to cloud builds.
- Cloud
Command - Applies calculated version values to a cloud-build provider.
- Cloud
Command Exception - An error from
CloudCommand. - Cloud
Command Options - Arguments accepted by
CloudCommand::set_build_variables. - Commit
Dates - The author and committer timestamps for a commit.
- Filter
Path - A filter (include or exclude) representing a repository-relative path.
- GitContext
- Represents a directory and selected commit within a Git repository.
- NuGet
Package Version Options - Settings controlling generated NuGet package versions.
- Prepare
Release Options - Options controlling one release preparation operation.
- Prepared
Release - The complete result of a release preparation operation.
- Release
Branch Info - Information about a branch created or updated during release preparation.
- Release
Info - Information about the branches affected by release preparation.
- Release
Manager - Creates or advances release branches and updates their version files.
- Release
Options - Settings for the
prepare-releaseandtagcommands. - Release
Preparation Exception - A release preparation failure with a stable classification and useful detail.
- Semantic
Version - Describes a numeric version with optional prerelease and build metadata.
- Version
- A two-, three-, or four-part numeric version.
- Version
File - Reads and writes version files for a Git context.
- Version
File Locations - Absolute locations discovered while resolving version files.
- Version
File Requirements - Controls which version file is returned and whether inheritance is merged.
- Version
Height Calculation - A version height and the commit that most recently contributed to it.
- Version
Options - Describes the versions and policies used by a build.
- Version
Oracle - The complete set of version values calculated for a project.
Enums§
- Cloud
Build Number Commit When - The conditions under which a commit ID is included in a cloud build number.
- Cloud
Build Number Commit Where - The position at which a commit ID appears in a cloud build number.
- Cloud
Command Error - The classified failures produced by
CloudCommand. - Error
- An error produced while reading a repository or calculating a version.
- GitContext
Kind - Describes what kind of context was created.
- GitEngine
- Selects how repository operations are performed.
- Release
Manager Output Mode - Selects the rendered output format.
- Release
Preparation Error - Classifies failures that can occur while preparing a release.
- Release
Version Increment - The component incremented after creating a release branch.
- Version
Position - Identifies positions in a semantic version.
- Version
Precision - 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§
- Release
Preparation Result - A result returned by release preparation.
- Result
- A result returned by this crate.