diff options
author | Dan Davison <dandavison7@gmail.com> | 2021-11-24 13:31:43 -0500 |
---|---|---|
committer | Dan Davison <dandavison7@gmail.com> | 2021-11-24 13:31:43 -0500 |
commit | 0c753d4bac691d30590ce152f61c6ce6568747d3 (patch) | |
tree | eff900f2ed690e74b77af737f78b0655afd68764 | |
parent | 8ff50afccb1d065b105db83eda19341c3458f964 (diff) |
-rw-r--r-- | src/cli.rs | 4 | ||||
-rw-r--r-- | src/handlers/blame.rs | 3 |
2 files changed, 4 insertions, 3 deletions
@@ -442,10 +442,10 @@ pub struct Opt { pub map_styles: Option<String>, /// Format string for git blame commit metadata. Available placeholders are - /// "{timestamp}", "{author}", and "{commit}". + /// "{timestamp}", "{author}", "{commit}", and "{line-number}". #[structopt( long = "blame-format", - default_value = "{timestamp:<15} {author:<15.14} {commit:<8} │ " + default_value = "{timestamp:<15} {author:<15.14} {commit:<8} {line-number:<5}│ " )] pub blame_format: String, diff --git a/src/handlers/blame.rs b/src/handlers/blame.rs index 629dc705..10e5e47b 100644 --- a/src/handlers/blame.rs +++ b/src/handlers/blame.rs @@ -227,7 +227,7 @@ pub fn parse_git_blame_line<'a>(line: &'a str, timestamp_format: &str) -> Option lazy_static! { pub static ref BLAME_PLACEHOLDER_REGEX: Regex = - format::make_placeholder_regex(&["timestamp", "author", "commit"]); + format::make_placeholder_regex(&["timestamp", "author", "commit", "line-number"]); } pub fn format_blame_metadata( @@ -254,6 +254,7 @@ pub fn format_blame_metadata( )), Some(Placeholder::Str("author")) => Some(Cow::from(blame.author)), Some(Placeholder::Str("commit")) => Some(delta::format_raw_line(blame.commit, config)), + Some(Placeholder::Str("line-number")) => Some(Cow::from(blame.line_number.to_string())), None => None, _ => unreachable!("Unexpected `git blame` input"), }; |