Only initialize worktrees for actually cloned repos
This commit is contained in:
@@ -143,6 +143,8 @@ fn sync_repo(root_path: &Path, repo: &RepoConfig, init_worktree: bool) -> Result
|
|||||||
let repo_path = root_path.join(&repo.name);
|
let repo_path = root_path.join(&repo.name);
|
||||||
let actual_git_directory = get_actual_git_directory(&repo_path, repo.worktree_setup);
|
let actual_git_directory = get_actual_git_directory(&repo_path, repo.worktree_setup);
|
||||||
|
|
||||||
|
let mut newly_created = false;
|
||||||
|
|
||||||
if repo_path.exists() {
|
if repo_path.exists() {
|
||||||
if repo.worktree_setup && !actual_git_directory.exists() {
|
if repo.worktree_setup && !actual_git_directory.exists() {
|
||||||
return Err(String::from(
|
return Err(String::from(
|
||||||
@@ -174,6 +176,8 @@ fn sync_repo(root_path: &Path, repo: &RepoConfig, init_worktree: bool) -> Result
|
|||||||
return Err(format!("Repository failed during clone: {}", e));
|
return Err(format!("Repository failed during clone: {}", e));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
newly_created = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
let repo_handle = match Repo::open(&repo_path, repo.worktree_setup) {
|
let repo_handle = match Repo::open(&repo_path, repo.worktree_setup) {
|
||||||
@@ -189,7 +193,7 @@ fn sync_repo(root_path: &Path, repo: &RepoConfig, init_worktree: bool) -> Result
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if repo.worktree_setup && init_worktree {
|
if newly_created && repo.worktree_setup && init_worktree {
|
||||||
match repo_handle.default_branch() {
|
match repo_handle.default_branch() {
|
||||||
Ok(branch) => {
|
Ok(branch) => {
|
||||||
add_worktree(&repo_path, &branch.name()?, None, None, false)?;
|
add_worktree(&repo_path, &branch.name()?, None, None, false)?;
|
||||||
|
|||||||
Reference in New Issue
Block a user