mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-25 11:08:11 +08:00
Refactor source of Git commit build info (closes #661)
This commit is contained in:
@@ -1,45 +0,0 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Provides metadata about the build environment.
|
||||
///
|
||||
/// This data is viewable in the editor via the [`crate::dialog::AboutGraphite`] dialog.
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct BuildMetadata {
|
||||
pub release: String,
|
||||
pub timestamp: String,
|
||||
pub hash: String,
|
||||
pub branch: String,
|
||||
}
|
||||
|
||||
impl Default for BuildMetadata {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
release: "unknown".to_string(),
|
||||
timestamp: "unknown".to_string(),
|
||||
hash: "unknown".to_string(),
|
||||
branch: "unknown".to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl BuildMetadata {
|
||||
pub fn release_series(&self) -> String {
|
||||
format!("Release Series: {}", self.release)
|
||||
}
|
||||
|
||||
pub fn commit_info(&self) -> String {
|
||||
format!("{}\n{}\n{}", self.commit_timestamp(), self.commit_hash(), self.commit_branch())
|
||||
}
|
||||
|
||||
pub fn commit_timestamp(&self) -> String {
|
||||
format!("Date: {}", self.timestamp)
|
||||
}
|
||||
|
||||
pub fn commit_hash(&self) -> String {
|
||||
format!("Hash: {}", self.hash)
|
||||
}
|
||||
|
||||
pub fn commit_branch(&self) -> String {
|
||||
format!("Branch: {}", self.branch)
|
||||
}
|
||||
}
|
||||
@@ -8,14 +8,11 @@ use crate::workspace::WorkspaceMessageHandler;
|
||||
|
||||
use std::collections::VecDeque;
|
||||
|
||||
use super::BuildMetadata;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct Dispatcher {
|
||||
message_queue: VecDeque<Message>,
|
||||
pub responses: Vec<FrontendMessage>,
|
||||
message_handlers: DispatcherMessageHandlers,
|
||||
build_metadata: BuildMetadata,
|
||||
}
|
||||
|
||||
#[remain::sorted]
|
||||
@@ -75,7 +72,7 @@ impl Dispatcher {
|
||||
Dialog(message) => {
|
||||
self.message_handlers
|
||||
.dialog_message_handler
|
||||
.process_action(message, (&self.build_metadata, &self.message_handlers.portfolio_message_handler), &mut self.message_queue);
|
||||
.process_action(message, &self.message_handlers.portfolio_message_handler, &mut self.message_queue);
|
||||
}
|
||||
Frontend(message) => {
|
||||
// Image and font loading should be immediately handled
|
||||
@@ -120,9 +117,6 @@ impl Dispatcher {
|
||||
.workspace_message_handler
|
||||
.process_action(message, &self.message_handlers.input_preprocessor_message_handler, &mut self.message_queue);
|
||||
}
|
||||
|
||||
#[remain::unsorted]
|
||||
PopulateBuildMetadata { new } => self.build_metadata = new,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use super::BuildMetadata;
|
||||
use crate::message_prelude::*;
|
||||
|
||||
use graphite_proc_macros::*;
|
||||
@@ -41,9 +40,6 @@ pub enum Message {
|
||||
Tool(ToolMessage),
|
||||
#[child]
|
||||
Workspace(WorkspaceMessage),
|
||||
|
||||
#[remain::unsorted]
|
||||
PopulateBuildMetadata { new: BuildMetadata },
|
||||
}
|
||||
|
||||
impl Message {
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
mod build_metadata;
|
||||
pub mod dispatcher;
|
||||
pub mod message;
|
||||
pub mod message_handler;
|
||||
|
||||
pub use crate::communication::dispatcher::*;
|
||||
pub use crate::input::InputPreprocessorMessageHandler;
|
||||
pub use build_metadata::BuildMetadata;
|
||||
|
||||
use rand_chacha::rand_core::{RngCore, SeedableRng};
|
||||
use rand_chacha::ChaCha20Rng;
|
||||
|
||||
Reference in New Issue
Block a user