summaryrefslogtreecommitdiffstats
path: root/src/config.rs
diff options
context:
space:
mode:
authorDan Davison <dandavison7@gmail.com>2021-11-11 10:50:57 -0500
committerDan Davison <dandavison7@gmail.com>2021-11-15 21:01:32 -0500
commit24a07ff9474dc8dc4942026b7d6c3804132cb047 (patch)
tree7beac02c6685c8487b1e07b2bc06540721d6e8ce /src/config.rs
parent57cabdcb6502afe5a05f9d53f3a6bcbf60a7ff5f (diff)
Handle `git blame` output
Fixes #426 Partial versions of these changes were previously in master and then reverted multiple times. See #746 0745f853d4bed52aca0b6739ac452d54ff54a153 3aab5d19569fa52ace2d7e6d196a1256990c4e20
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/config.rs b/src/config.rs
index 770a9eb6..3cba6ba3 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -57,6 +57,9 @@ fn adapt_wrap_max_lines_argument(arg: String) -> usize {
pub struct Config {
pub available_terminal_width: usize,
pub background_color_extends_to_terminal_width: bool,
+ pub blame_format: String,
+ pub blame_palette: Vec<String>,
+ pub blame_timestamp_format: String,
pub color_only: bool,
pub commit_regex: Regex,
pub commit_style: Style,
@@ -213,6 +216,8 @@ impl From<cli::Opt> for Config {
_ => *style::GIT_DEFAULT_PLUS_STYLE,
};
+ let blame_palette = make_blame_palette(opt.blame_palette, opt.computed.is_light_mode);
+
let file_added_label = opt.file_added_label;
let file_copied_label = opt.file_copied_label;
let file_modified_label = opt.file_modified_label;
@@ -257,6 +262,9 @@ impl From<cli::Opt> for Config {
background_color_extends_to_terminal_width: opt
.computed
.background_color_extends_to_terminal_width,
+ blame_format: opt.blame_format,
+ blame_palette,
+ blame_timestamp_format: opt.blame_timestamp_format,
commit_style,
color_only: opt.color_only,
commit_regex,
@@ -603,6 +611,23 @@ fn make_commit_file_hunk_header_styles(opt: &cli::Opt) -> (Style, Style, Style,
)
}
+fn make_blame_palette(blame_palette: Option<String>, is_light_mode: bool) -> Vec<String> {
+ match (blame_palette, is_light_mode) {
+ (Some(string), _) => string
+ .split_whitespace()
+ .map(|s| s.to_owned())
+ .collect::<Vec<String>>(),
+ (None, true) => color::LIGHT_THEME_BLAME_PALETTE
+ .iter()
+ .map(|s| s.to_string())
+ .collect::<Vec<String>>(),
+ (None, false) => color::DARK_THEME_BLAME_PALETTE
+ .iter()
+ .map(|s| s.to_string())
+ .collect::<Vec<String>>(),
+ }
+}
+
/// Did the user supply `option` on the command line?
pub fn user_supplied_option(option: &str, arg_matches: &clap::ArgMatches) -> bool {
arg_matches.occurrences_of(option) > 0