Skip to content

Commit 94889b3

Browse files
committed
refactor(core): re-export formatting symbols from cursive_core
This should have been done from the beginning, since we operate on these symbols in several places for formatting. This would also help a migration away from `cursive`, since now only two modules have direct dependencies on `cursive`/`cursive_core`: - git-branchless-lib for general output formatting. - git-branchless-undo for the interactive undo UI.
1 parent 235f224 commit 94889b3

File tree

26 files changed

+41
-77
lines changed

26 files changed

+41
-77
lines changed

Cargo.lock

Lines changed: 1 addition & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

git-branchless-invoke/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ version = "0.9.0"
1111
[dependencies]
1212
clap = { workspace = true, features = ["derive"] }
1313
color-eyre = { workspace = true }
14-
cursive_core = { workspace = true }
1514
eyre = { workspace = true }
1615
git-branchless-opts = { workspace = true }
1716
git2 = { workspace = true }

git-branchless-invoke/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,11 @@ use std::path::PathBuf;
2121
use std::time::SystemTime;
2222

2323
use clap::{CommandFactory, FromArgMatches, Parser};
24-
use cursive_core::theme::BaseColor;
25-
use cursive_core::utils::markup::StyledString;
2624
use eyre::Context;
2725
use git_branchless_opts::{ColorSetting, GlobalArgs};
2826
use lib::core::config::env_vars::{get_git_exec_path, get_path_to_git};
2927
use lib::core::effects::Effects;
30-
use lib::core::formatting::Glyphs;
28+
use lib::core::formatting::{BaseColor, Glyphs, StyledString};
3129
use lib::git::GitRunInfo;
3230
use lib::git::{Repo, RepoError};
3331
use lib::util::{ExitCode, EyreExitOr};

git-branchless-lib/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ chrono = { workspace = true }
5151
color-eyre = { workspace = true }
5252
concolor = { workspace = true }
5353
console = { workspace = true }
54-
cursive = { workspace = true }
54+
cursive_core = { workspace = true }
5555
eden_dag = { workspace = true }
5656
eyre = { workspace = true }
5757
futures = { workspace = true }

git-branchless-lib/src/core/check_out.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ use std::ffi::{OsStr, OsString};
44
use std::fmt::Write;
55
use std::time::{SystemTime, UNIX_EPOCH};
66

7-
use cursive::theme::BaseColor;
8-
use cursive::utils::markup::StyledString;
97
use eyre::Context;
108
use itertools::Itertools;
119
use tracing::instrument;
1210

1311
use crate::core::config::get_auto_switch_branches;
12+
use crate::core::formatting::{BaseColor, StyledString};
1413
use crate::git::{
1514
update_index, CategorizedReferenceName, GitRunInfo, MaybeZeroOid, NonZeroOid, ReferenceName,
1615
Repo, Stage, UpdateIndexCommand, WorkingCopySnapshot,

git-branchless-lib/src/core/config.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ use std::ffi::OsString;
44
use std::fmt::Write;
55
use std::path::PathBuf;
66

7-
use cursive::theme::{BaseColor, Effect, Style};
8-
use cursive::utils::markup::StyledString;
97
use eyre::Context;
108
use tracing::{instrument, warn};
119

12-
use crate::core::formatting::StyledStringBuilder;
10+
use crate::core::formatting::{BaseColor, Effect, Style, StyledString, StyledStringBuilder};
1311
use crate::git::{ConfigRead, GitRunInfo, GitRunOpts, Repo};
1412

1513
use super::effects::Effects;

git-branchless-lib/src/core/formatting.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
77
use std::fmt::Display;
88

9-
use cursive::theme::{Effect, Style};
10-
use cursive::utils::markup::StyledString;
11-
use cursive::utils::span::Span;
9+
pub use cursive_core::theme::{BaseColor, Color, ColorType, Effect, Style};
10+
pub use cursive_core::utils::markup::StyledString;
11+
pub use cursive_core::utils::span::Span;
1212

1313
/// Pluralize a quantity, as appropriate. Example:
1414
///
@@ -369,7 +369,6 @@ fn render_style_as_ansi(content: &str, style: Style) -> eyre::Result<String> {
369369
let Style { effects, color } = style;
370370
let output = {
371371
use console::style;
372-
use cursive::theme::{BaseColor, Color, ColorType};
373372
let output = content.to_string();
374373
match color.front {
375374
ColorType::Palette(_) => {

git-branchless-lib/src/core/node_descriptors.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ use std::sync::{Arc, Mutex};
88
use std::time::SystemTime;
99

1010
use bstr::{ByteSlice, ByteVec};
11-
use cursive::theme::BaseColor;
12-
use cursive::utils::markup::StyledString;
1311
use lazy_static::lazy_static;
1412
use regex::Regex;
1513
use tracing::instrument;
@@ -18,15 +16,15 @@ use crate::core::config::{
1816
get_commit_descriptors_branches, get_commit_descriptors_differential_revision,
1917
get_commit_descriptors_relative_time,
2018
};
19+
use crate::core::eventlog::{Event, EventCursor, EventReplayer};
20+
use crate::core::formatting::Glyphs;
21+
use crate::core::formatting::{BaseColor, StyledString, StyledStringBuilder};
22+
use crate::core::repo_ext::RepoReferencesSnapshot;
23+
use crate::core::rewrite::find_rewrite_target;
2124
use crate::git::{
2225
CategorizedReferenceName, Commit, NonZeroOid, ReferenceName, Repo, ResolvedReferenceInfo,
2326
};
2427

25-
use super::eventlog::{Event, EventCursor, EventReplayer};
26-
use super::formatting::{Glyphs, StyledStringBuilder};
27-
use super::repo_ext::RepoReferencesSnapshot;
28-
use super::rewrite::find_rewrite_target;
29-
3028
/// An object which can be rendered in the smartlog.
3129
#[derive(Clone, Debug)]
3230
pub enum NodeObject<'repo> {

git-branchless-lib/src/git/object.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
use std::path::Path;
22

33
use bstr::{BString, ByteSlice};
4-
use cursive::theme::BaseColor;
5-
use cursive::utils::markup::StyledString;
64
use git2::message_trailers_bytes;
75
use tracing::instrument;
86

9-
use crate::core::formatting::{Glyphs, StyledStringBuilder};
7+
use crate::core::formatting::{BaseColor, Glyphs, StyledString, StyledStringBuilder};
108
use crate::core::node_descriptors::{
119
render_node_descriptors, CommitMessageDescriptor, CommitOidDescriptor, NodeObject, Redactor,
1210
};

git-branchless-lib/src/git/repo.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,14 @@ use std::{io, time};
2020

2121
use bstr::ByteVec;
2222
use chrono::NaiveDateTime;
23-
use cursive::theme::BaseColor;
24-
use cursive::utils::markup::StyledString;
2523
use git2::DiffOptions;
2624
use itertools::Itertools;
2725
use thiserror::Error;
2826
use tracing::{instrument, warn};
2927

3028
use crate::core::effects::{Effects, OperationType};
3129
use crate::core::eventlog::EventTransactionId;
32-
use crate::core::formatting::Glyphs;
30+
use crate::core::formatting::{BaseColor, Glyphs, StyledString};
3331
use crate::git::config::{Config, ConfigRead};
3432
use crate::git::object::Blob;
3533
use crate::git::oid::{make_non_zero_oid, MaybeZeroOid, NonZeroOid};

0 commit comments

Comments
 (0)