1mod detect;
8mod error;
9#[cfg(feature = "git-parse")]
10mod parse_git;
11#[cfg(feature = "jj-parse")]
12mod parse_jj;
13mod runner;
14mod types;
15
16pub use detect::{VcsBackend, detect_vcs};
17pub use error::RunError;
18#[cfg(feature = "git-parse")]
19pub use parse_git::parse_git_diff_name_status;
20#[cfg(feature = "jj-parse")]
21pub use parse_jj::{
22 BOOKMARK_TEMPLATE, LOG_TEMPLATE, BookmarkParseResult, LogParseResult, parse_bookmark_output,
23 parse_diff_summary, parse_log_output, parse_remote_list,
24};
25pub use runner::{
26 git_merge_base, is_transient_error, jj_merge_base, run_git, run_git_with_retry,
27 run_git_with_timeout, run_jj, run_jj_with_retry, run_jj_with_timeout,
28};
29
30pub use procpilot::{
33 Cmd, CmdDisplay, DefaultRunner, Redirection, RetryPolicy, RunOutput, Runner,
34 STREAM_SUFFIX_SIZE, SpawnedProcess, StdinData, binary_available, binary_version,
35 default_transient,
36};
37
38#[cfg(any(feature = "jj-parse", feature = "git-parse"))]
39pub use types::{FileChange, FileChangeKind};
40#[cfg(feature = "jj-parse")]
41pub use types::{Bookmark, ConflictState, ContentState, GitRemote, LogEntry, RemoteStatus, WorkingCopy};
42
43pub mod prelude {
56 pub use procpilot::prelude::*;
57
58 pub use crate::{
59 VcsBackend, detect_vcs, git_available, git_merge_base, git_version, is_transient_error,
60 jj_available, jj_merge_base, jj_version, run_git, run_git_with_retry, run_git_with_timeout,
61 run_jj, run_jj_with_retry, run_jj_with_timeout,
62 };
63}
64
65pub fn jj_available() -> bool {
67 binary_available("jj")
68}
69
70pub fn jj_version() -> Option<String> {
72 binary_version("jj")
73}
74
75pub fn git_available() -> bool {
77 binary_available("git")
78}
79
80pub fn git_version() -> Option<String> {
82 binary_version("git")
83}
84
85#[cfg(test)]
86mod tests {
87 use super::*;
88
89 #[test]
90 fn jj_available_returns_bool() {
91 let _ = jj_available();
92 }
93
94 #[test]
95 fn jj_version_matches_availability() {
96 if jj_available() {
97 let v = jj_version().expect("jj is installed");
98 assert!(v.contains("jj"));
99 } else {
100 assert!(jj_version().is_none());
101 }
102 }
103
104 #[test]
105 fn git_available_returns_bool() {
106 let _ = git_available();
107 }
108
109 #[test]
110 fn git_version_matches_availability() {
111 if git_available() {
112 let v = git_version().expect("git is installed");
113 assert!(v.contains("git"));
114 } else {
115 assert!(git_version().is_none());
116 }
117 }
118}