Debian Codegraph @

src/handlers/submodule.rs

raw symbols SCIP
1 use lazy_staticrust-analyzer cargo lazy_static 1.4.0 crate/::lazy_staticrust-analyzer cargo lazy_static 1.4.0 lazy_static!;
2 use regexrust-analyzer cargo regex 1.12.3 crate/::Regexrust-analyzer cargo regex 1.12.3 regex/string/Regex#;
3
4 use craterust-analyzer cargo git-delta 0.19.2 crate/::deltarust-analyzer cargo git-delta 0.19.2 delta/::{Staterust-analyzer cargo git-delta 0.19.2 delta/State#, StateMachinerust-analyzer cargo git-delta 0.19.2 delta/StateMachine#};
5
6 impl StateMachinerust-analyzer cargo git-delta 0.19.2 delta/StateMachine#<'_> {
7 #[inline]
8 fn test_submodule_logrust-analyzer cargo git-delta 0.19.2 handlers/submodule/impl#[`StateMachine<'_>`]test_submodule_log().(&self) -> bool {
9 self.linerust-analyzer cargo git-delta 0.19.2 delta/StateMachine#line..starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().("Submodule ")
10 }
11
12 pub fn handle_submodule_log_linerust-analyzer cargo git-delta 0.19.2 handlers/submodule/impl#[`StateMachine<'_>`]handle_submodule_log_line().(&mut self) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<bool> {
13 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.test_submodule_logrust-analyzer cargo git-delta 0.19.2 handlers/submodule/impl#[`StateMachine<'_>`]test_submodule_log().() {
14 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(false);
15 }
16 self.handle_additional_casesrust-analyzer cargo git-delta 0.19.2 handlers/impl#[`StateMachine<'_>`]handle_additional_cases().(Staterust-analyzer cargo git-delta 0.19.2 delta/State#::SubmoduleLogrust-analyzer cargo git-delta 0.19.2 delta/State#SubmoduleLog#)
17 }
18
19 #[inline]
20 fn test_submodule_short_linerust-analyzer cargo git-delta 0.19.2 handlers/submodule/impl#[`StateMachine<'_>`]test_submodule_short_line().(&self) -> bool {
21 matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(self.staterust-analyzer cargo git-delta 0.19.2 delta/StateMachine#state., Staterust-analyzer cargo git-delta 0.19.2 delta/State#::HunkHeaderrust-analyzer cargo git-delta 0.19.2 delta/State#HunkHeader#(_, _, _, _))
22 && self.linerust-analyzer cargo git-delta 0.19.2 delta/StateMachine#line..starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().("-Subproject commit ")
23 || matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(self.staterust-analyzer cargo git-delta 0.19.2 delta/StateMachine#state., Staterust-analyzer cargo git-delta 0.19.2 delta/State#::SubmoduleShortrust-analyzer cargo git-delta 0.19.2 delta/State#SubmoduleShort#(_))
24 && self.linerust-analyzer cargo git-delta 0.19.2 delta/StateMachine#line..starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().("+Subproject commit ")
25 }
26
27 pub fn handle_submodule_short_linerust-analyzer cargo git-delta 0.19.2 handlers/submodule/impl#[`StateMachine<'_>`]handle_submodule_short_line().(&mut self) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<bool> {
28 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.test_submodule_short_linerust-analyzer cargo git-delta 0.19.2 handlers/submodule/impl#[`StateMachine<'_>`]test_submodule_short_line().() || self.configrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#config..color_onlyrust-analyzer cargo git-delta 0.19.2 config/Config#color_only. {
29 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(false);
30 }
31 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(commit) = get_submodule_short_commitrust-analyzer cargo git-delta 0.19.2 handlers/submodule/get_submodule_short_commit().(&self.linerust-analyzer cargo git-delta 0.19.2 delta/StateMachine#line.) {
32 if let Staterust-analyzer cargo git-delta 0.19.2 delta/State#::HunkHeaderrust-analyzer cargo git-delta 0.19.2 delta/State#HunkHeader#(_, _, _, _) = self.staterust-analyzer cargo git-delta 0.19.2 delta/StateMachine#state. {
33 self.staterust-analyzer cargo git-delta 0.19.2 delta/StateMachine#state. = Staterust-analyzer cargo git-delta 0.19.2 delta/State#::SubmoduleShortrust-analyzer cargo git-delta 0.19.2 delta/State#SubmoduleShort#(commit.to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().());
34 } else if let Staterust-analyzer cargo git-delta 0.19.2 delta/State#::SubmoduleShortrust-analyzer cargo git-delta 0.19.2 delta/State#SubmoduleShort#(minus_commit) = &self.staterust-analyzer cargo git-delta 0.19.2 delta/StateMachine#state. {
35 self.painterrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#painter..emitrust-analyzer cargo git-delta 0.19.2 paint/impl#[`Painter<'p>`]emit().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
36 writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(
37 self.painterrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#painter..writerrust-analyzer cargo git-delta 0.19.2 paint/Painter#writer.,
38 "{}..{}",
39 self.configrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#config.
40 .minus_stylerust-analyzer cargo git-delta 0.19.2 config/Config#minus_style.
41 .paintrust-analyzer cargo git-delta 0.19.2 style/impl#[Style]paint().(minus_commit.charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().().takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take().(12).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>()),
42 self.configrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#config.
43 .plus_stylerust-analyzer cargo git-delta 0.19.2 config/Config#plus_style.
44 .paintrust-analyzer cargo git-delta 0.19.2 style/impl#[Style]paint().(commit.charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().().takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take().(12).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>()),
45 )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
46 }
47 }
48 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(true)
49 }
50 }
51
52 lazy_staticrust-analyzer cargo lazy_static 1.4.0 lazy_static!! {
53 static ref SUBMODULE_SHORT_LINE_REGEXrust-analyzer cargo git-delta 0.19.2 handlers/submodule/SUBMODULE_SHORT_LINE_REGEX#: Regexrust-analyzer cargo regex 1.12.3 regex/string/Regex# =
54 Regexrust-analyzer cargo regex 1.12.3 regex/string/Regex#::newrust-analyzer cargo regex 1.12.3 regex/string/impl#[Regex]new().("^[-+]Subproject commit ([0-9a-f]{40})(-dirty)?$").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
55 }
56
57 pub fn get_submodule_short_commitrust-analyzer cargo git-delta 0.19.2 handlers/submodule/get_submodule_short_commit().(line: &str) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&str> {
58 match SUBMODULE_SHORT_LINE_REGEXrust-analyzer cargo git-delta 0.19.2 handlers/submodule/SUBMODULE_SHORT_LINE_REGEX..capturesrust-analyzer cargo regex 1.12.3 regex/string/impl#[Regex]captures().(line) {
59 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(caps) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(caps.getrust-analyzer cargo regex 1.12.3 regex/string/impl#[`Captures<'h>`]get().(1).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().as_strrust-analyzer cargo regex 1.12.3 regex/string/impl#[`Match<'h>`]as_str().()),
60 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
61 }
62 }