1pub mod audit;
2pub mod backends;
3mod cache;
4pub mod config;
5mod files;
6mod gitignore;
7pub mod globbing;
8mod hashes;
9pub mod init;
10pub mod paths;
11pub mod progress;
12pub(crate) mod utils;
13
14pub use backends::Backend;
15pub use config::Compression;
16pub use files::add::{AddDetail, AddResult, add_files};
17pub use files::get::{GetDetail, GetResult, get_files};
18pub use files::metadata::FileMetadata;
19pub use files::status::{FileStatus, StatusDetail, get_status};
20pub use files::types::{Outcome, Status};
21pub use hashes::{HashAlg, Hashes};
22pub use paths::{AddPathStatus, DvsPaths, PathFilter, find_repo_root};
23pub use progress::FileProgress;
24pub use utils::{format_size, set_num_threads};
25
26pub const VERSION: &str = env!("CARGO_PKG_VERSION");
27
28#[cfg(test)]
29pub mod testutil {
30 use crate::config::Config;
31 use crate::init::init;
32 use fs_err as fs;
33 use std::path::{Path, PathBuf};
34 use tempfile::TempDir;
35
36 pub fn create_temp_git_repo() -> (TempDir, PathBuf) {
42 let tmp = tempfile::tempdir().unwrap();
43 let repo_root = fs::canonicalize(tmp.path()).unwrap().join("repo");
47 fs::create_dir(&repo_root).unwrap();
48 fs::create_dir(repo_root.join(".git")).unwrap();
49 (tmp, repo_root)
50 }
51
52 pub fn create_file(dir: &Path, relative_path: &str, content: &[u8]) -> PathBuf {
56 let path = dir.join(relative_path);
57 if let Some(parent) = path.parent() {
58 fs::create_dir_all(parent).ok();
59 }
60 fs::write(&path, content).unwrap();
61 path
62 }
63
64 pub fn init_dvs_repo(repo_root: &Path) -> (Config, PathBuf) {
69 let storage_dir = repo_root.parent().unwrap().join(".storage");
70 let config = Config::new_local(&storage_dir, None).unwrap();
71 init(repo_root, config.clone()).unwrap();
72 let dvs_dir = repo_root.join(".dvs");
73 (config, dvs_dir)
74 }
75}