summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Davison <dandavison7@gmail.com>2021-11-24 13:31:43 -0500
committerDan Davison <dandavison7@gmail.com>2021-11-24 13:31:43 -0500
commit0c753d4bac691d30590ce152f61c6ce6568747d3 (patch)
treeeff900f2ed690e74b77af737f78b0655afd68764
parent8ff50afccb1d065b105db83eda19341c3458f964 (diff)
-rw-r--r--src/cli.rs4
-rw-r--r--src/handlers/blame.rs3
2 files changed, 4 insertions, 3 deletions
diff --git a/src/cli.rs b/src/cli.rs
index ee0f8272..6c30d90d 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -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"),
};