mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-18 14:00:39 +00:00
feat: add common_version customization (#7869)
* feat: add product name customization * chore: update tests
This commit is contained in:
@@ -43,14 +43,19 @@ impl Function for VersionFunction {
|
||||
let version = match func_ctx.query_ctx.channel() {
|
||||
Channel::Mysql => {
|
||||
format!(
|
||||
"{}-greptimedb-{}",
|
||||
"{}-{}-{}",
|
||||
std::env::var("GREPTIMEDB_MYSQL_SERVER_VERSION")
|
||||
.unwrap_or_else(|_| "8.4.2".to_string()),
|
||||
common_version::product_name(),
|
||||
common_version::version()
|
||||
)
|
||||
}
|
||||
Channel::Postgres => {
|
||||
format!("PostgreSQL 16.3 GreptimeDB {}", common_version::version())
|
||||
format!(
|
||||
"PostgreSQL 16.3 {} {}",
|
||||
common_version::product_name(),
|
||||
common_version::version()
|
||||
)
|
||||
}
|
||||
_ => common_version::version().to_string(),
|
||||
};
|
||||
|
||||
@@ -29,6 +29,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let refresh = profile == "release";
|
||||
|
||||
println!("cargo:rerun-if-env-changed=RUSTC");
|
||||
println!("cargo:rerun-if-env-changed=GREPTIME_PRODUCT_NAME");
|
||||
|
||||
// The "CARGO_WORKSPACE_DIR" is set manually (not by Rust itself) in Cargo config file, to
|
||||
// solve the problem where the "CARGO_MANIFEST_DIR" is not what we want when this repo is
|
||||
@@ -44,6 +45,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let product_version = load_product_version(&workspace_root);
|
||||
println!("cargo:rustc-env=GREPTIME_PRODUCT_VERSION={product_version}");
|
||||
|
||||
let product_name = load_product_name();
|
||||
println!("cargo:rustc-env=GREPTIME_PRODUCT_NAME={product_name}");
|
||||
|
||||
let repository = open_repository(&workspace_root);
|
||||
|
||||
if refresh {
|
||||
@@ -100,6 +104,10 @@ fn load_product_version(workspace_root: &Path) -> String {
|
||||
.unwrap_or_else(|| env::var("CARGO_PKG_VERSION").unwrap())
|
||||
}
|
||||
|
||||
fn load_product_name() -> String {
|
||||
env::var("GREPTIME_PRODUCT_NAME").unwrap_or_else(|_| "GreptimeDB".to_string())
|
||||
}
|
||||
|
||||
fn emit_workspace_watch_list(
|
||||
workspace_root: &Path,
|
||||
repository: Option<&Repository>,
|
||||
|
||||
@@ -109,6 +109,10 @@ pub const fn version() -> &'static str {
|
||||
BUILD_INFO.version
|
||||
}
|
||||
|
||||
pub const fn product_name() -> &'static str {
|
||||
env!("GREPTIME_PRODUCT_NAME")
|
||||
}
|
||||
|
||||
pub const fn verbose_version() -> &'static str {
|
||||
const_format::formatcp!(
|
||||
"\nbranch: {}\ncommit: {}\nclean: {}\nversion: {}",
|
||||
|
||||
Reference in New Issue
Block a user