Skip to main content

nerdbank_gitversioning/
lib.rs

1//! Git-based semantic version calculation compatible with Nerdbank.GitVersioning.
2//!
3//! This crate computes deterministic versions from `version.json` or `version.txt`
4//! files and Git history. It intentionally does not provide MSBuild integration.
5//! It supports current stable Rust on Windows, Linux, and macOS.
6//!
7//! # Example
8//!
9//! ```no_run
10//! use nerdbank_gitversioning::{GitContext, GitEngine, VersionOracle};
11//!
12//! fn main() -> Result<(), nerdbank_gitversioning::Error> {
13//!     let context = GitContext::create(".", None, GitEngine::ReadOnly)?;
14//!     let version = VersionOracle::new(&context, None)?.sem_ver2();
15//!     println!("{version}");
16//!     Ok(())
17//! }
18//! ```
19
20#![warn(missing_docs)]
21
22pub mod cloud;
23pub mod cloud_build_services;
24mod cloud_command;
25mod error;
26mod filter_path;
27mod git_context;
28mod history;
29mod release_manager;
30mod semantic_version;
31mod version;
32mod version_file;
33mod version_options;
34mod version_oracle;
35
36pub use cloud_command::{
37    CloudCommand, CloudCommandError, CloudCommandException, CloudCommandOptions,
38};
39
40pub use error::{Error, Result};
41pub use filter_path::FilterPath;
42pub use git_context::{CommitDates, GitContext, GitContextKind, GitEngine, effective_git_engine};
43pub use history::{
44    MAXIMUM_VERSION_COMPONENT, VersionHeightCalculation, calculate_version_height, encode_version,
45    get_commit_from_version, get_commits_from_version, get_height, get_id_as_version,
46    get_version_height, truncated_commit_id,
47};
48pub use release_manager::{
49    PrepareReleaseOptions, PreparedRelease, ReleaseBranchInfo, ReleaseInfo, ReleaseManager,
50    ReleaseManagerOutputMode, ReleasePreparationError, ReleasePreparationException,
51    ReleasePreparationResult, format_release_branch_name, format_release_tag_name,
52};
53pub use semantic_version::{SemanticVersion, VersionPosition};
54pub use version::Version;
55pub use version_file::{
56    VERSION_JSON_FILE_NAME, VERSION_SCHEMA, VERSION_TXT_FILE_NAME, VersionFile,
57    VersionFileLocations, VersionFileRequirements,
58};
59pub use version_options::{
60    AssemblyVersionOptions, CloudBuildNumberCommitIdOptions, CloudBuildNumberCommitWhen,
61    CloudBuildNumberCommitWhere, CloudBuildNumberOptions, CloudBuildOptions,
62    NuGetPackageVersionOptions, ReleaseOptions, ReleaseVersionIncrement, VersionOptions,
63    VersionPrecision,
64};
65pub use version_oracle::VersionOracle;