Debian Codegraph @

src/handlers/commit_meta.rs

raw symbols SCIP
1 use std::borrow::Cow;
2
3 use super::draw;
4 use crate::delta::{State, StateMachine};
5 use crate::features;
6
7 impl StateMachine<'_> {
8 #[inline]
9 fn test_commit_meta_header_line(&self) -> bool {
10 self.config.commit_regex.is_match(&self.line)
11 }
12
13 pub fn handle_commit_meta_header_line(&mut self) -> std::io::Result<bool> {
14 if !self.test_commit_meta_header_line() {
15 return Ok(false);
16 }
17 let mut handled_line = false;
18 self.painter.paint_buffered_minus_and_plus_lines();
19 self.handle_pending_line_with_diff_name()?;
20 self.state = State::CommitMeta;
21 if self.should_handle() {
22 self.painter.emit()?;
23 self._handle_commit_meta_header_line()?;
24 handled_line = true
25 }
26 Ok(handled_line)
27 }
28
29 fn _handle_commit_meta_header_line(&mut self) -> std::io::Result<()> {
30 if self.config.commit_style.is_omitted {
31 return Ok(());
32 }
33 let (mut draw_fn, pad, decoration_ansi_term_style) =
34 draw::get_draw_function(self.config.commit_style.decoration_style);
35 let (formatted_line, formatted_raw_line) = if self.config.hyperlinks {
36 (
37 features::hyperlinks::format_commit_line_with_osc8_commit_hyperlink(
38 &self.line,
39 self.config,
40 ),
41 features::hyperlinks::format_commit_line_with_osc8_commit_hyperlink(
42 &self.raw_line,
43 self.config,
44 ),
45 )
46 } else {
47 (Cow::from(&self.line), Cow::from(&self.raw_line))
48 };
49
50 draw_fn(
51 self.painter.writer,
52 &format!("{}{}", formatted_line, if pad { " " } else { "" }),
53 &format!("{}{}", formatted_raw_line, if pad { " " } else { "" }),
54 "",
55 &self.config.decorations_width,
56 self.config.commit_style,
57 decoration_ansi_term_style,
58 )?;
59 Ok(())
60 }
61 }