Refactor source of Git commit build info (closes #661)

This commit is contained in:
Keavon Chambers
2022-05-24 14:33:58 -07:00
parent c73f8a64a0
commit eca9797597
17 changed files with 126 additions and 118 deletions
@@ -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)
}
}
+1 -7
View File
@@ -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,
}
}
}
-4
View File
@@ -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 {
-2
View File
@@ -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;