diff options
author | Daniel García <[email protected]> | 2022-01-23 23:40:59 +0100 |
---|---|---|
committer | Daniel García <[email protected]> | 2022-01-23 23:40:59 +0100 |
commit | f4a9645b54f1c7361799c394360fdc079df9f502 (patch) | |
tree | 790ed707718711e01b68945e268972fd2bd75662 /build.rs | |
parent | 8ba6e61fd591e7fe038fb13fd24b0e263c87e88a (diff) | |
download | vaultwarden-f4a9645b54f1c7361799c394360fdc079df9f502.tar.gz vaultwarden-f4a9645b54f1c7361799c394360fdc079df9f502.zip |
Remove references to "bwrs" #2195
Squashed commit of the following:
commit 1bdf1c7954e0731c95703d10118f3874ab5155d3
Merge: 8ba6e61 7257251
Author: Daniel García <[email protected]>
Date: Sun Jan 23 23:40:17 2022 +0100
Merge branch 'remove-bwrs' of https://github.com/RealOrangeOne/vaultwarden into RealOrangeOne-remove-bwrs
commit 7257251ecf23af18deb894e8f2e5519a15360c76
Author: Jake Howard <[email protected]>
Date: Thu Jan 6 17:48:18 2022 +0000
Use `or_else` to save potentially unnecessary function call
commit 40ae81dd3c43a596375d5bfdcc00053e786328cc
Author: Jake Howard <[email protected]>
Date: Wed Jan 5 21:18:24 2022 +0000
Move $BWRS_VERSION fallback into build.rs
commit 743ef74b307a662960f3ca1b9636f3608506516d
Author: Jake Howard <[email protected]>
Date: Sat Jan 1 23:08:27 2022 +0000
Revert "Add feature to enable use of `Option::or` in const context"
This reverts commit fe8e043b8aaf77c083747bf11760f29b53df0bba.
We want to run on stable soon, where these features are not supported
commit a1f0da638c8b6ba32209318b105bde1efdd47082
Author: Jake Howard <[email protected]>
Date: Sat Jan 1 13:04:47 2022 +0000
Rename web vault version file
https://github.com/dani-garcia/bw_web_builds/pull/58
commit fe8e043b8aaf77c083747bf11760f29b53df0bba
Author: Jake Howard <[email protected]>
Date: Sat Jan 1 12:56:44 2022 +0000
Add feature to enable use of `Option::or` in const context
commit 687435c8b2b995e90bf6f0ee619bc305e37bc183
Author: Jake Howard <[email protected]>
Date: Sat Jan 1 12:27:28 2022 +0000
Continue to allow using `$BWRS_VERSION`
commit 8e2f708e5037db8071251c582ebaf1a97d8e5923
Author: Jake Howard <[email protected]>
Date: Fri Dec 31 11:41:34 2021 +0000
Remove references to "bwrs"
The only remaining one is getting the version of the web vault, which requires coordinating with the web vault patching.
Diffstat (limited to 'build.rs')
-rw-r--r-- | build.rs | 41 |
1 files changed, 19 insertions, 22 deletions
@@ -15,11 +15,14 @@ fn main() { "You need to enable one DB backend. To build with previous defaults do: cargo build --features sqlite" ); - if let Ok(version) = env::var("BWRS_VERSION") { - println!("cargo:rustc-env=BWRS_VERSION={}", version); + // Support $BWRS_VERSION for legacy compatibility, but default to $VW_VERSION. + // If neither exist, read from git. + let maybe_vaultwarden_version = + env::var("VW_VERSION").or_else(|_| env::var("BWRS_VERSION")).or_else(|_| version_from_git_info()); + + if let Ok(version) = maybe_vaultwarden_version { + println!("cargo:rustc-env=VW_VERSION={}", version); println!("cargo:rustc-env=CARGO_PKG_VERSION={}", version); - } else { - read_git_info().ok(); } } @@ -33,7 +36,13 @@ fn run(args: &[&str]) -> Result<String, std::io::Error> { } /// This method reads info from Git, namely tags, branch, and revision -fn read_git_info() -> Result<(), std::io::Error> { +/// To access these values, use: +/// - env!("GIT_EXACT_TAG") +/// - env!("GIT_LAST_TAG") +/// - env!("GIT_BRANCH") +/// - env!("GIT_REV") +/// - env!("VW_VERSION") +fn version_from_git_info() -> Result<String, std::io::Error> { // The exact tag for the current commit, can be empty when // the current commit doesn't have an associated tag let exact_tag = run(&["git", "describe", "--abbrev=0", "--tags", "--exact-match"]).ok(); @@ -56,23 +65,11 @@ fn read_git_info() -> Result<(), std::io::Error> { println!("cargo:rustc-env=GIT_REV={}", rev_short); // Combined version - let version = if let Some(exact) = exact_tag { - exact + if let Some(exact) = exact_tag { + Ok(exact) } else if &branch != "main" && &branch != "master" { - format!("{}-{} ({})", last_tag, rev_short, branch) + Ok(format!("{}-{} ({})", last_tag, rev_short, branch)) } else { - format!("{}-{}", last_tag, rev_short) - }; - - println!("cargo:rustc-env=BWRS_VERSION={}", version); - println!("cargo:rustc-env=CARGO_PKG_VERSION={}", version); - - // To access these values, use: - // env!("GIT_EXACT_TAG") - // env!("GIT_LAST_TAG") - // env!("GIT_BRANCH") - // env!("GIT_REV") - // env!("BWRS_VERSION") - - Ok(()) + Ok(format!("{}-{}", last_tag, rev_short)) + } } |