Skip to content

Commit

Permalink
refactor: allow custom version (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
kwaa authored Jun 16, 2024
1 parent 57dda79 commit 066d188
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
6 changes: 3 additions & 3 deletions crates/api_mastodon/src/entities/instance.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use activitypub_federation::config::Data;
use hatsu_utils::{AppData, AppError};
use hatsu_utils::{AppData, AppError, VERSION};
use serde::{Deserialize, Serialize};
use serde_json::{json, Value};
use url::Url;
Expand Down Expand Up @@ -33,13 +33,13 @@ impl Instance {
.hatsu_node_name
.clone()
.unwrap_or_else(|| String::from("Hatsu")),
version: String::from(env!("CARGO_PKG_VERSION")),
version: String::from(VERSION),
source_url: Url::parse("https://github.com/importantimport/hatsu")?,
description: data
.env
.hatsu_node_description
.clone()
.unwrap_or_else(|| String::from(env!("CARGO_PKG_DESCRIPTION"))),
.unwrap_or_else(|| String::from(VERSION)),
usage: json!({
"users": {
"active_month": 0
Expand Down
6 changes: 3 additions & 3 deletions crates/nodeinfo/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use hatsu_db_schema::{
prelude::{Post, User},
user,
};
use hatsu_utils::{AppData, AppError};
use hatsu_utils::{AppData, AppError, VERSION};
use sea_orm::{ColumnTrait, EntityTrait, PaginatorTrait, QueryFilter};
use serde::{Deserialize, Serialize};
use utoipa::ToSchema;
Expand All @@ -30,7 +30,7 @@ impl NodeInfo {
version: String::from("2.0"),
software: NodeInfoSoftware {
name: String::from("hatsu"),
version: String::from(env!("CARGO_PKG_VERSION")),
version: String::from(VERSION),
repository: None,
homepage: None,
},
Expand All @@ -47,7 +47,7 @@ impl NodeInfo {
version: String::from("2.1"),
software: NodeInfoSoftware {
name: String::from("hatsu"),
version: String::from(env!("CARGO_PKG_VERSION")),
version: String::from(VERSION),
repository: Some(String::from(env!("CARGO_PKG_REPOSITORY"))),
homepage: Some(String::from(env!("CARGO_PKG_HOMEPAGE"))),
},
Expand Down
4 changes: 2 additions & 2 deletions crates/utils/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::env;

use sea_orm::DatabaseConnection;

use crate::AppError;
use crate::{AppError, VERSION};

#[derive(Clone, Debug)]
pub struct AppData {
Expand Down Expand Up @@ -41,7 +41,7 @@ impl AppEnv {

#[must_use]
pub fn info() -> String {
let version = env!("CARGO_PKG_VERSION");
let version = VERSION;
let codename = "celluloid";

format!("Hatsu v{version} \"{codename}\"")
Expand Down
2 changes: 2 additions & 0 deletions crates/utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ pub mod date;
mod error;
pub mod markdown;
pub mod url;
mod version;

pub use data::{AppData, AppEnv};
pub use error::AppError;
pub use version::VERSION;
1 change: 1 addition & 0 deletions crates/utils/src/version.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub const VERSION: &str = env!("CARGO_PKG_VERSION");

0 comments on commit 066d188

Please sign in to comment.