-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
109 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use std::process::Command; | ||
use std::sync::LazyLock; | ||
|
||
use crate::constants::REACTION_EMOJIS; | ||
|
||
pub static INFO: LazyLock<Info> = LazyLock::new(Info::load); | ||
|
||
#[derive(Clone)] | ||
pub struct Info { | ||
pub git_commit_hash: String, | ||
pub git_commit_short_hash: String, | ||
pub reaction_emojis: Vec<String>, | ||
pub version: String, | ||
} | ||
|
||
impl Info { | ||
fn load() -> Self { | ||
let output = Command::new("git") | ||
.args(["rev-parse", "HEAD"]) | ||
.output() | ||
.expect("could not get git commit hash"); | ||
|
||
let git_commit_hash = String::from_utf8(output.stdout).expect("could not parse git commit hash"); | ||
|
||
Self { | ||
git_commit_hash: git_commit_hash.clone(), | ||
git_commit_short_hash: git_commit_hash[0..7].to_owned(), | ||
reaction_emojis: REACTION_EMOJIS.clone().iter().map(|s| (*s).to_owned()).collect(), | ||
version: env!("CARGO_PKG_VERSION").to_owned(), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[cfg(feature = "ssr")] | ||
use mango3_core::info::Info; | ||
|
||
#[derive(Clone, Default, Deserialize, Serialize)] | ||
pub struct InfoResp { | ||
pub git_commit_hash: String, | ||
pub git_commit_short_hash: String, | ||
pub reaction_emojis: Vec<String>, | ||
pub version: String, | ||
} | ||
|
||
#[cfg(feature = "ssr")] | ||
impl From<Info> for InfoResp { | ||
fn from(info: Info) -> Self { | ||
Self { | ||
git_commit_hash: info.git_commit_hash.clone(), | ||
git_commit_short_hash: info.git_commit_short_hash, | ||
reaction_emojis: info.reaction_emojis, | ||
version: info.version, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters