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