Skip to content

Commit 592b461

Browse files
authored
Merge pull request #10501 from gitbutlerapp/kv-branch-55
fix(status): initialize repo if Project::find_by_path fails and
2 parents e06a008 + 1a68fd5 commit 592b461

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

crates/but/src/status/mod.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,15 @@ pub(crate) fn worktree(
3939
show_files: bool,
4040
verbose: bool,
4141
) -> anyhow::Result<()> {
42-
let project = Project::find_by_path(repo_path).expect("Failed to create project from path");
42+
let project = match Project::find_by_path(repo_path) {
43+
Ok(p) => Ok(p),
44+
Err(_e) => {
45+
crate::init::repo(repo_path, json, false)?;
46+
Project::find_by_path(repo_path)
47+
}
48+
}?;
49+
50+
// let project = Project::find_by_path(repo_path).expect("Failed to create project from path");
4351
let ctx = &mut CommandContext::open(&project, AppSettings::load_from_default_path_creating()?)?;
4452
but_rules::process_rules(ctx).ok(); // TODO: this is doing double work (dependencies can be reused)
4553

0 commit comments

Comments
 (0)