1mod detect;
2mod error;
3#[cfg(feature = "git-parse")]
4mod parse_git;
5#[cfg(feature = "jj-parse")]
6mod parse_jj;
7mod runner;
8mod types;
9
10pub use detect::{VcsBackend, detect_vcs};
11pub use error::RunError;
12#[cfg(feature = "git-parse")]
13pub use parse_git::parse_git_diff_name_status;
14#[cfg(feature = "jj-parse")]
15pub use parse_jj::{
16 BOOKMARK_TEMPLATE, LOG_TEMPLATE, BookmarkParseResult, LogParseResult, parse_bookmark_output,
17 parse_diff_summary, parse_log_output, parse_remote_list,
18};
19pub use runner::{
20 RunOutput, binary_available, binary_version, git_merge_base, is_transient_error, jj_merge_base,
21 run_cmd, run_cmd_in, run_cmd_in_with_env, run_cmd_in_with_timeout, run_cmd_inherited, run_git,
22 run_git_with_retry, run_git_with_timeout, run_jj, run_jj_with_retry, run_jj_with_timeout,
23 run_with_retry,
24};
25#[cfg(any(feature = "jj-parse", feature = "git-parse"))]
26pub use types::{FileChange, FileChangeKind};
27#[cfg(feature = "jj-parse")]
28pub use types::{Bookmark, ConflictState, ContentState, GitRemote, LogEntry, RemoteStatus, WorkingCopy};
29
30pub fn jj_available() -> bool {
32 binary_available("jj")
33}
34
35pub fn jj_version() -> Option<String> {
37 binary_version("jj")
38}
39
40pub fn git_available() -> bool {
42 binary_available("git")
43}
44
45pub fn git_version() -> Option<String> {
47 binary_version("git")
48}
49
50#[cfg(test)]
51mod tests {
52 use super::*;
53
54 #[test]
55 fn jj_available_returns_bool() {
56 let _ = jj_available();
57 }
58
59 #[test]
60 fn jj_version_returns_option() {
61 let version = jj_version();
62 if jj_available() {
63 let v = version.expect("should have version when jj is available");
64 assert!(v.contains("jj"));
65 } else {
66 assert!(version.is_none());
67 }
68 }
69
70 #[test]
71 fn git_available_returns_bool() {
72 let _ = git_available();
73 }
74
75 #[test]
76 fn git_version_returns_option() {
77 let version = git_version();
78 if git_available() {
79 let v = version.expect("should have version when git is available");
80 assert!(v.contains("git"));
81 } else {
82 assert!(version.is_none());
83 }
84 }
85}