Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose some internal constructors #4189

Merged
merged 2 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions lib/src/repo.rs
torquestomp marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,26 @@ pub struct RepoLoader {
}

impl RepoLoader {
pub fn new(
repo_path: PathBuf,
repo_settings: RepoSettings,
store: Arc<Store>,
op_store: Arc<dyn OpStore>,
op_heads_store: Arc<dyn OpHeadsStore>,
index_store: Arc<dyn IndexStore>,
submodule_store: Arc<dyn SubmoduleStore>,
) -> Self {
Self {
repo_path,
repo_settings,
store,
op_store,
op_heads_store,
index_store,
submodule_store,
}
}

pub fn init(
user_settings: &UserSettings,
repo_path: &Path,
Expand Down
18 changes: 15 additions & 3 deletions lib/src/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,17 +131,29 @@ fn init_working_copy(
}

impl Workspace {
fn new(
pub fn new(
workspace_root: &Path,
working_copy: Box<dyn WorkingCopy>,
repo_loader: RepoLoader,
) -> Result<Workspace, PathError> {
let workspace_root = workspace_root.canonicalize().context(workspace_root)?;
Ok(Workspace {
Ok(Self::new_no_canonicalize(
workspace_root,
working_copy,
repo_loader,
))
}

pub fn new_no_canonicalize(
workspace_root: PathBuf,
working_copy: Box<dyn WorkingCopy>,
repo_loader: RepoLoader,
) -> Self {
Self {
workspace_root,
repo_loader,
working_copy,
})
}
}

pub fn init_local(
Expand Down