diff options
| author | Ellie Huxtable <ellie@elliehuxtable.com> | 2023-12-20 09:03:04 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-20 09:03:04 +0000 |
| commit | 86f50e0356e4b661be43c2aeba97a67d83910095 (patch) | |
| tree | 3c836616132ab23e60231af21b668d639dbabe97 /atuin-common/src/api.rs | |
| parent | chore(deps): bump lukemathwalker/cargo-chef (#1425) (diff) | |
| download | atuin-86f50e0356e4b661be43c2aeba97a67d83910095.zip | |
feat: add semver checking to client requests (#1456)
* feat: add semver checking to client requests
This enforces that the client and the server run the same major version
in order to sync successfully.
We're using the `Atuin-Version` http header to transfer this information
If the user is not on the same MAJOR, then they will see an error like
this
> Atuin version mismatch! In order to successfully sync, the client and the server must run the same *major* version
> Client: 17.1.0
> Server: 18.1.0
> Error: could not sync records due to version mismatch
This change means two things
1. We will now only increment major versions if there is a breaking
change for sync
2. We can now add breaking changes to sync, for any version >17.1.0.
Clients will fail in a meaningful way.
* lint, fmt, etc
* only check for client newer than server
* Add version header to client too
Diffstat (limited to '')
| -rw-r--r-- | atuin-common/src/api.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/atuin-common/src/api.rs b/atuin-common/src/api.rs index ddcc0b09..b608937f 100644 --- a/atuin-common/src/api.rs +++ b/atuin-common/src/api.rs @@ -1,7 +1,18 @@ +use lazy_static::lazy_static; +use semver::Version; use serde::{Deserialize, Serialize}; use std::borrow::Cow; use time::OffsetDateTime; +// the usage of X- has been deprecated for quite along time, it turns out +pub static ATUIN_HEADER_VERSION: &str = "Atuin-Version"; +pub static ATUIN_CARGO_VERSION: &str = env!("CARGO_PKG_VERSION"); + +lazy_static! { + pub static ref ATUIN_VERSION: Version = + Version::parse(ATUIN_CARGO_VERSION).expect("failed to parse self semver"); +} + #[derive(Debug, Serialize, Deserialize)] pub struct UserResponse { pub username: String, |
