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, Redirection, RetryPolicy, RunOutput, STREAM_SUFFIX_SIZE, SpawnedProcess,
34 StdinData, binary_available, binary_version, default_transient,
35};
36
37#[cfg(any(feature = "jj-parse", feature = "git-parse"))]
38pub use types::{FileChange, FileChangeKind};
39#[cfg(feature = "jj-parse")]
40pub use types::{Bookmark, ConflictState, ContentState, GitRemote, LogEntry, RemoteStatus, WorkingCopy};
41
42pub mod prelude {
55 pub use procpilot::prelude::*;
56
57 pub use crate::{
58 VcsBackend, detect_vcs, git_available, git_merge_base, git_version, is_transient_error,
59 jj_available, jj_merge_base, jj_version, run_git, run_git_with_retry, run_git_with_timeout,
60 run_jj, run_jj_with_retry, run_jj_with_timeout,
61 };
62}
63
64pub fn jj_available() -> bool {
66 binary_available("jj")
67}
68
69pub fn jj_version() -> Option<String> {
71 binary_version("jj")
72}
73
74pub fn git_available() -> bool {
76 binary_available("git")
77}
78
79pub fn git_version() -> Option<String> {
81 binary_version("git")
82}
83
84#[cfg(test)]
85mod tests {
86 use super::*;
87
88 #[test]
89 fn jj_available_returns_bool() {
90 let _ = jj_available();
91 }
92
93 #[test]
94 fn jj_version_matches_availability() {
95 if jj_available() {
96 let v = jj_version().expect("jj is installed");
97 assert!(v.contains("jj"));
98 } else {
99 assert!(jj_version().is_none());
100 }
101 }
102
103 #[test]
104 fn git_available_returns_bool() {
105 let _ = git_available();
106 }
107
108 #[test]
109 fn git_version_matches_availability() {
110 if git_available() {
111 let v = git_version().expect("git is installed");
112 assert!(v.contains("git"));
113 } else {
114 assert!(git_version().is_none());
115 }
116 }
117}