Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new: Additional version tokens #34

Merged
merged 4 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions tools/internal-schema/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

#### 🚀 Updates

- Added new version tokens: `{versionMinor}`, `{versionPatch}`, `{versionMonth}`, `{versionDay}`, and deprecated `{versionMajorMinor}` and `{versionYearMonth}`.

## 0.16.3

#### 🚀 Updates
Expand Down
2 changes: 1 addition & 1 deletion tools/internal-schema/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "schema_tool"
version = "0.16.3"
version = "0.16.4"
edition = "2021"
license = "MIT"
publish = false
Expand Down
27 changes: 20 additions & 7 deletions tools/internal-schema/src/proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,24 +228,37 @@ fn interpolate_tokens(

if let Some(v) = version.as_version() {
let major = v.major.to_string();
let major_minor = format!("{}.{}", v.major, v.minor);
let year_month = format!("{:0>4}-{:0>2}", v.major, v.minor);
let minor = v.minor.to_string();
let patch = v.patch.to_string();
let year = format!("{:0>4}", v.major);
let month = format!("{:0>2}", v.minor);
let day = format!("{:0>2}", v.patch);
let major_minor = format!("{}.{}", v.major, v.minor); // Deprecated, remains for backwards compatibility
let year_month = format!("{:0>4}-{:0>2}", v.major, v.minor); // Deprecated, remains for backwards compatibility
tom-fletcher marked this conversation as resolved.
Show resolved Hide resolved
let pre = v.pre.to_string();
let build = v.build.to_string();

value = value
.replace("{versionMajor}", &major)
.replace("{versionMajorMinor}", &major_minor)
.replace("{versionYear}", &major)
.replace("{versionYearMonth}", &year_month)
.replace("{versionMinor}", &minor)
.replace("{versionPatch}", &patch)
.replace("{versionMajorMinor}", &major_minor) // Deprecated, remains for backwards compatibility
.replace("{versionYear}", &year)
.replace("{versionMonth}", &month)
.replace("{versionDay}", &day)
.replace("{versionYearMonth}", &year_month) // Deprecated, remains for backwards compatibility
.replace("{versionPrerelease}", &pre)
.replace("{versionBuild}", &build);
} else {
value = value
.replace("{versionMajor}", "")
.replace("{versionMajorMinor}", "")
.replace("{versionMinor}", "")
.replace("{versionPatch}", "")
.replace("{versionMajorMinor}", "") // Deprecated, remains for backwards compatibility
.replace("{versionYear}", "")
.replace("{versionYearMonth}", "")
.replace("{versionMonth}", "")
.replace("{versionDay}", "")
.replace("{versionYearMonth}", "") // Deprecated, remains for backwards compatibility
.replace("{versionPrerelease}", "")
.replace("{versionBuild}", "");
}
Expand Down
Loading