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_inherited, run_git, run_git_with_retry, run_jj,
18 run_jj_with_retry, run_with_retry,
19};
20#[cfg(feature = "jj-parse")]
21pub use types::{
22 Bookmark, ConflictState, ContentState, GitRemote, LogEntry, RemoteStatus, WorkingCopy,
23};
24
25pub fn jj_available() -> bool {
27 binary_available("jj")
28}
29
30pub fn jj_version() -> Option<String> {
32 binary_version("jj")
33}
34
35pub fn git_available() -> bool {
37 binary_available("git")
38}
39
40pub fn git_version() -> Option<String> {
42 binary_version("git")
43}
44
45#[cfg(test)]
46mod tests {
47 use super::*;
48
49 #[test]
50 fn jj_available_returns_bool() {
51 let _ = jj_available();
52 }
53
54 #[test]
55 fn jj_version_returns_option() {
56 let version = jj_version();
57 if jj_available() {
58 let v = version.expect("should have version when jj is available");
59 assert!(v.contains("jj"));
60 } else {
61 assert!(version.is_none());
62 }
63 }
64
65 #[test]
66 fn git_available_returns_bool() {
67 let _ = git_available();
68 }
69
70 #[test]
71 fn git_version_returns_option() {
72 let version = git_version();
73 if git_available() {
74 let v = version.expect("should have version when git is available");
75 assert!(v.contains("git"));
76 } else {
77 assert!(version.is_none());
78 }
79 }
80}