mod detect;
mod error;
#[cfg(feature = "git-parse")]
mod parse_git;
#[cfg(feature = "jj-parse")]
mod parse_jj;
mod runner;
mod types;
pub use detect::{VcsBackend, detect_vcs};
pub use error::RunError;
#[cfg(feature = "git-parse")]
pub use parse_git::parse_git_diff_name_status;
#[cfg(feature = "jj-parse")]
pub use parse_jj::{
BOOKMARK_TEMPLATE, LOG_TEMPLATE, BookmarkParseResult, LogParseResult, parse_bookmark_output,
parse_diff_summary, parse_log_output, parse_remote_list,
};
pub use runner::{
RunOutput, binary_available, binary_version, git_merge_base, is_transient_error, jj_merge_base,
run_cmd, run_cmd_in, run_cmd_in_with_env, run_cmd_in_with_timeout, run_cmd_inherited, run_git,
run_git_with_retry, run_git_with_timeout, run_jj, run_jj_with_retry, run_jj_with_timeout,
run_with_retry,
};
#[cfg(any(feature = "jj-parse", feature = "git-parse"))]
pub use types::{FileChange, FileChangeKind};
#[cfg(feature = "jj-parse")]
pub use types::{Bookmark, ConflictState, ContentState, GitRemote, LogEntry, RemoteStatus, WorkingCopy};
pub fn jj_available() -> bool {
binary_available("jj")
}
pub fn jj_version() -> Option<String> {
binary_version("jj")
}
pub fn git_available() -> bool {
binary_available("git")
}
pub fn git_version() -> Option<String> {
binary_version("git")
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn jj_available_returns_bool() {
let _ = jj_available();
}
#[test]
fn jj_version_returns_option() {
let version = jj_version();
if jj_available() {
let v = version.expect("should have version when jj is available");
assert!(v.contains("jj"));
} else {
assert!(version.is_none());
}
}
#[test]
fn git_available_returns_bool() {
let _ = git_available();
}
#[test]
fn git_version_returns_option() {
let version = git_version();
if git_available() {
let v = version.expect("should have version when git is available");
assert!(v.contains("git"));
} else {
assert!(version.is_none());
}
}
}