Skip to content

Commit a8386e9

Browse files
committed
fix(but): fix various minor review comments
1 parent 0b8d11c commit a8386e9

2 files changed

Lines changed: 4 additions & 14 deletions

File tree

crates/but/src/lib.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,6 @@ pub async fn handle_args(args: impl Iterator<Item = OsString>) -> Result<()> {
143143
.filter(|p| p.exists())
144144
.and_then(|p| theme::load(&p).ok())
145145
.unwrap_or_default();
146-
tracing::warn!(
147-
"{:?}",
148-
dirs::config_dir().map(|dir| dir.join("gitbutler").join("but-theme.json"))
149-
);
150-
tracing::warn!("{:?}", theme);
151146
theme::init(theme);
152147
}
153148

crates/but/src/theme.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! A global, serializable color theme for CLI output.
22
//!
33
//! Styled output *must* begin from one of the global theme's styles. Using [`colored`] or [`Style`]
4-
//! indepentently of this theme is prohibited, as that breaks user-defined theming.
4+
//! independently of this theme is prohibited, as that breaks user-defined theming.
55
//!
66
//! The theme controls the styling of semantic elements (branch names, commit IDs, file statuses,
77
//! etc.) for human-readable output modes. It can be loaded from a JSON file so users can customize
@@ -12,8 +12,8 @@
1212
//! Call [`init`] exactly once before any output is produced (typically in [`crate::handle_args`]).
1313
//! After that, [`get`] returns a `&'static Theme`.
1414
//!
15-
//! Note that unit tests **do not need to initialize** the theme as we always return the hard-coded
16-
//! default for tests.
15+
//! Note that unit tests **do not need to initializes** the theme as they will automatically fall
16+
//! back on the default if not initialized.
1717
//!
1818
//!
1919
//! # Serialization
@@ -52,12 +52,7 @@ pub fn init(theme: Theme) {
5252
pub fn get() -> &'static Theme {
5353
#[cfg(test)]
5454
{
55-
let theme = THEME.get();
56-
if let Some(theme) = theme {
57-
return theme;
58-
}
59-
let _ = THEME.set(Theme::default());
60-
get()
55+
THEME.get_or_init(Theme::default)
6156
}
6257
#[cfg(not(test))]
6358
{

0 commit comments

Comments
 (0)