Skip to content

Commit 7abc186

Browse files
committed
Use short version string for --version flag in cli and launcher
1 parent d348c64 commit 7abc186

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

crates/aspect-cli/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::env::var;
88
use std::path::PathBuf;
99
use std::process::ExitCode;
1010

11-
use aspect_telemetry::{cargo_pkg_version, do_not_track, send_telemetry};
11+
use aspect_telemetry::{cargo_pkg_short_version, cargo_pkg_version, do_not_track, send_telemetry};
1212
use axl_runtime::engine::task::{FrozenTask, Task};
1313
use axl_runtime::engine::task_arg::TaskArg;
1414
use axl_runtime::engine::task_args::TaskArgs;
@@ -239,7 +239,7 @@ async fn main() -> miette::Result<ExitCode> {
239239
// customize the usage string to use <TASK>
240240
.subcommand_value_name("TASK")
241241
// handle --version and -v flags
242-
.version(cargo_pkg_version())
242+
.version(cargo_pkg_short_version())
243243
.disable_version_flag(true) // disable auto -V / --version
244244
.arg(
245245
Arg::new("version")

crates/aspect-launcher/src/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::env::current_dir;
22
use std::path::{Path, PathBuf};
33
use std::{collections::HashMap, fmt::Debug, fs};
44

5-
use aspect_telemetry::cargo_pkg_version;
5+
use aspect_telemetry::cargo_pkg_short_version;
66
use serde::Deserialize;
77

88
const AXL_MODULE_FILE: &str = "MODULE.aspect";
@@ -33,7 +33,7 @@ fn default_cli_sources() -> Vec<ToolSource> {
3333
pub struct CliConfig {
3434
#[serde(default = "default_cli_sources")]
3535
sources: Vec<ToolSource>,
36-
#[serde(default = "cargo_pkg_version")]
36+
#[serde(default = "cargo_pkg_short_version")]
3737
version: String,
3838
}
3939

crates/aspect-launcher/src/main.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ use std::process::ExitCode;
1313
use std::str::FromStr;
1414

1515
use aspect_telemetry::{
16-
cargo_pkg_version, do_not_track, send_telemetry, BZLARCH, BZLOS, GOARCH, GOOS, LLVM_TRIPLE,
16+
cargo_pkg_short_version, do_not_track, send_telemetry, BZLARCH, BZLOS, GOARCH, GOOS,
17+
LLVM_TRIPLE,
1718
};
1819
use clap::{arg, Arg, Command};
1920
use fork::{fork, Fork};
@@ -301,8 +302,8 @@ fn main() -> Result<ExitCode> {
301302
let matches = cmd.get_matches();
302303

303304
if matches.get_flag("version") {
304-
let v = cargo_pkg_version();
305-
println!("Aspect CLI Launcher {v:}");
305+
let v = cargo_pkg_short_version();
306+
println!("aspect launcher {v:}");
306307
return Ok(ExitCode::SUCCESS);
307308
}
308309

crates/aspect-telemetry/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ pub fn cargo_pkg_version() -> String {
3131
.into()
3232
}
3333

34+
/// A short variant of the monorepo version. For examples, 2025.34.0 if the monorepo
35+
/// version was 2025.34.0+201b9a8. See https://blog.aspect.build/versioning-releases-from-a-monorepo.
36+
pub fn cargo_pkg_short_version() -> String {
37+
let s = cargo_pkg_version();
38+
match s.find('+') {
39+
Some(i) => s[..i].to_string(),
40+
None => s,
41+
}
42+
}
43+
3444
pub fn do_not_track() -> bool {
3545
var("DO_NOT_TRACK").is_ok()
3646
}

0 commit comments

Comments
 (0)