1mod detect;
8mod error;
9#[cfg(feature = "git-parse")]
10mod parse_git;
11#[cfg(feature = "jj-parse")]
12mod parse_jj;
13mod runner;
14mod types;
15mod worktree;
16
17pub use detect::{VcsBackend, detect_vcs};
18pub use error::RunError;
19#[cfg(feature = "git-parse")]
20pub use parse_git::parse_git_diff_name_status;
21#[cfg(feature = "jj-parse")]
22pub use parse_jj::{
23 BOOKMARK_TEMPLATE, LOG_TEMPLATE, BookmarkParseResult, LogParseResult, parse_bookmark_output,
24 parse_diff_summary, parse_log_output, parse_remote_list,
25};
26pub use runner::{
27 git_merge_base, is_transient_error, jj_current_operation_id, jj_divergent_change_ids,
28 jj_is_divergent_at_operation, jj_merge_base, jj_op_restore, jj_operation_log,
29 jj_revset_at_operation, jj_revset_history, run_git,
30 run_git_cancellable, run_git_utf8, run_git_utf8_cancellable, run_git_utf8_with_retry,
31 run_git_utf8_with_retry_cancellable, run_git_utf8_with_timeout, run_git_with_retry,
32 run_git_with_retry_cancellable, run_git_with_timeout, run_jj, run_jj_cancellable, run_jj_utf8,
33 run_jj_utf8_cancellable, run_jj_utf8_ignore_wc, run_jj_utf8_with_retry,
34 run_jj_utf8_with_retry_cancellable, run_jj_utf8_with_timeout, run_jj_with_retry,
35 run_jj_with_retry_cancellable, run_jj_with_timeout,
36};
37
38pub use procpilot::{
41 Cmd, CmdDisplay, DefaultRunner, Redirection, RetryPolicy, RunOutput, Runner,
42 STREAM_SUFFIX_SIZE, SpawnedProcess, StdinData, binary_available, binary_version,
43 default_transient,
44};
45
46pub use worktree::{read_working_file, read_working_file_bytes, working_file_is_binary};
47
48pub use types::JjOperation;
49#[cfg(any(feature = "jj-parse", feature = "git-parse"))]
50pub use types::{FileChange, FileChangeKind};
51#[cfg(feature = "jj-parse")]
52pub use types::{Bookmark, ConflictState, ContentState, GitRemote, LogEntry, RemoteStatus, WorkingCopy};
53
54pub mod prelude {
67 pub use procpilot::prelude::*;
68
69 pub use crate::{
70 VcsBackend, detect_vcs, git_available, git_merge_base, git_version, is_transient_error,
71 jj_available, jj_current_operation_id, jj_divergent_change_ids,
72 jj_is_divergent_at_operation, jj_merge_base, jj_op_restore, jj_operation_log,
73 jj_revset_at_operation, jj_revset_history, jj_version,
74 run_git, run_git_cancellable, run_git_utf8, run_git_utf8_cancellable,
75 run_git_utf8_with_retry, run_git_utf8_with_retry_cancellable, run_git_utf8_with_timeout,
76 run_git_with_retry, run_git_with_retry_cancellable, run_git_with_timeout, run_jj,
77 run_jj_cancellable, run_jj_utf8, run_jj_utf8_cancellable, run_jj_utf8_ignore_wc,
78 run_jj_utf8_with_retry, run_jj_utf8_with_retry_cancellable, run_jj_utf8_with_timeout,
79 run_jj_with_retry, run_jj_with_retry_cancellable, run_jj_with_timeout,
80 read_working_file, read_working_file_bytes, working_file_is_binary,
81 };
82}
83
84pub fn jj_available() -> bool {
86 binary_available("jj")
87}
88
89pub fn jj_version() -> Option<String> {
91 binary_version("jj")
92}
93
94pub fn git_available() -> bool {
96 binary_available("git")
97}
98
99pub fn git_version() -> Option<String> {
101 binary_version("git")
102}
103
104#[cfg(test)]
105mod tests {
106 use super::*;
107
108 #[test]
109 fn jj_available_returns_bool() {
110 let _ = jj_available();
111 }
112
113 #[test]
114 fn jj_version_matches_availability() {
115 if jj_available() {
116 let v = jj_version().expect("jj is installed");
117 assert!(v.contains("jj"));
118 } else {
119 assert!(jj_version().is_none());
120 }
121 }
122
123 #[test]
124 fn git_available_returns_bool() {
125 let _ = git_available();
126 }
127
128 #[test]
129 fn git_version_matches_availability() {
130 if git_available() {
131 let v = git_version().expect("git is installed");
132 assert!(v.contains("git"));
133 } else {
134 assert!(git_version().is_none());
135 }
136 }
137}