Skip to content

Commit bc3656f

Browse files
committed
fix: move type_to_string func to strings.rs and rename
1 parent 30cad4d commit bc3656f

File tree

2 files changed

+31
-30
lines changed

2 files changed

+31
-30
lines changed

src/popups/checkout_option.rs

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::components::{
33
DrawableComponent, EventState,
44
};
55
use crate::queue::{InternalEvent, NeedsUpdate};
6+
use crate::strings::{checkout_option_to_string, CheckoutOptions};
67
use crate::try_or_popup;
78
use crate::{
89
app::Environment,
@@ -24,35 +25,6 @@ use ratatui::{
2425
Frame,
2526
};
2627

27-
#[derive(PartialEq, Clone, Copy)]
28-
enum CheckoutOptions {
29-
StashAndReapply,
30-
Unchange,
31-
Discard,
32-
}
33-
34-
const fn type_to_string(
35-
kind: CheckoutOptions,
36-
) -> (&'static str, &'static str) {
37-
const CHECKOUT_OPTION_STASH_AND_REAPPLY: &str =
38-
" 🟢 Stash and reapply changes";
39-
const CHECKOUT_OPTION_UNCHANGE: &str = " 🟡 Keep local changes";
40-
const CHECKOUT_OPTION_DISCARD: &str =
41-
" 🔴 Discard all local changes";
42-
43-
match kind {
44-
CheckoutOptions::StashAndReapply => {
45-
("Stash and reapply", CHECKOUT_OPTION_STASH_AND_REAPPLY)
46-
}
47-
CheckoutOptions::Unchange => {
48-
("Don't change", CHECKOUT_OPTION_UNCHANGE)
49-
}
50-
CheckoutOptions::Discard => {
51-
("Discard", CHECKOUT_OPTION_DISCARD)
52-
}
53-
}
54-
}
55-
5628
pub struct CheckoutOptionPopup {
5729
queue: Queue,
5830
repo: RepoPath,
@@ -93,7 +65,7 @@ impl CheckoutOptionPopup {
9365
),
9466
]));
9567

96-
let (kind_name, kind_desc) = type_to_string(self.option);
68+
let (kind_name, kind_desc) = checkout_option_to_string(self.option);
9769

9870
txt.push(Line::from(vec![
9971
Span::styled(

src/strings.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,35 @@ pub fn ellipsis_trim_start(s: &str, width: usize) -> Cow<str> {
438438
}
439439
}
440440

441+
#[derive(PartialEq, Clone, Copy)]
442+
pub enum CheckoutOptions {
443+
StashAndReapply,
444+
Unchange,
445+
Discard,
446+
}
447+
448+
pub fn checkout_option_to_string(
449+
kind: CheckoutOptions,
450+
) -> (&'static str, &'static str) {
451+
const CHECKOUT_OPTION_STASH_AND_REAPPLY: &str =
452+
" 🟢 Stash and reapply changes";
453+
const CHECKOUT_OPTION_UNCHANGE: &str = " 🟡 Keep local changes";
454+
const CHECKOUT_OPTION_DISCARD: &str =
455+
" 🔴 Discard all local changes";
456+
457+
match kind {
458+
CheckoutOptions::StashAndReapply => {
459+
("Stash and reapply", CHECKOUT_OPTION_STASH_AND_REAPPLY)
460+
}
461+
CheckoutOptions::Unchange => {
462+
("Don't change", CHECKOUT_OPTION_UNCHANGE)
463+
}
464+
CheckoutOptions::Discard => {
465+
("Discard", CHECKOUT_OPTION_DISCARD)
466+
}
467+
}
468+
}
469+
441470
pub mod commit {
442471
use crate::keys::SharedKeyConfig;
443472

0 commit comments

Comments
 (0)