Added forgotten file, fixed CI.
This commit is contained in:
@@ -94,9 +94,10 @@ jobs:
|
|||||||
name: darwin-arm64
|
name: darwin-arm64
|
||||||
bin_path: ./target/release/alfis
|
bin_path: ./target/release/alfis
|
||||||
archive_cmd: zip
|
archive_cmd: zip
|
||||||
- os: macos-13
|
- os: macos-latest
|
||||||
name: darwin-amd64
|
name: darwin-amd64
|
||||||
bin_path: ./target/release/alfis
|
target: x86_64-apple-darwin
|
||||||
|
bin_path: ./target/x86_64-apple-darwin/release/alfis
|
||||||
archive_cmd: zip
|
archive_cmd: zip
|
||||||
|
|
||||||
defaults:
|
defaults:
|
||||||
@@ -108,6 +109,8 @@ jobs:
|
|||||||
|
|
||||||
- name: Install Rust toolchain
|
- name: Install Rust toolchain
|
||||||
uses: dtolnay/rust-toolchain@stable
|
uses: dtolnay/rust-toolchain@stable
|
||||||
|
with:
|
||||||
|
targets: ${{ matrix.target || '' }}
|
||||||
|
|
||||||
- name: Install Linux dependencies
|
- name: Install Linux dependencies
|
||||||
if: contains(matrix.os, 'ubuntu')
|
if: contains(matrix.os, 'ubuntu')
|
||||||
@@ -121,7 +124,7 @@ jobs:
|
|||||||
libayatana-appindicator3-dev
|
libayatana-appindicator3-dev
|
||||||
|
|
||||||
- name: Build release binaries
|
- name: Build release binaries
|
||||||
run: cargo build --release
|
run: cargo build --release ${{ matrix.target && format('--target {0}', matrix.target) || '' }}
|
||||||
|
|
||||||
- name: Package zip
|
- name: Package zip
|
||||||
env:
|
env:
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
use std::fmt;
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||||
|
pub struct Version {
|
||||||
|
pub major: u16,
|
||||||
|
pub minor: u16,
|
||||||
|
pub patch: u16,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Version {
|
||||||
|
pub fn parse(s: &str) -> Version {
|
||||||
|
let parts: Vec<&str> = s.split('.').collect();
|
||||||
|
Version {
|
||||||
|
major: parts.get(0).and_then(|s| s.parse().ok()).unwrap_or(0),
|
||||||
|
minor: parts.get(1).and_then(|s| s.parse().ok()).unwrap_or(0),
|
||||||
|
patch: parts.get(2).and_then(|s| s.parse().ok()).unwrap_or(0),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Version {
|
||||||
|
fn default() -> Self {
|
||||||
|
Version { major: 0, minor: 0, patch: 0 }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PartialOrd for Version {
|
||||||
|
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
|
||||||
|
Some(self.cmp(other))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Ord for Version {
|
||||||
|
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
|
||||||
|
self.major.cmp(&other.major)
|
||||||
|
.then(self.minor.cmp(&other.minor))
|
||||||
|
.then(self.patch.cmp(&other.patch))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for Version {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
write!(f, "{}.{}.{}", self.major, self.minor, self.patch)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_version_comparison() {
|
||||||
|
assert!(Version::parse("0.8.9") >= Version::parse("0.8.9"));
|
||||||
|
assert!(Version::parse("0.8.10") > Version::parse("0.8.9"));
|
||||||
|
assert!(Version::parse("0.8.8") < Version::parse("0.8.9"));
|
||||||
|
assert!(Version::parse("0.9.0") > Version::parse("0.8.99"));
|
||||||
|
assert!(Version::parse("1.0.0") > Version::parse("0.99.99"));
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user