Skip to content

Commit 5df41d2

Browse files
authored
Merge pull request #10436 from gitbutlerapp/kv-branch-55
fix(project): match projects by canonicalized path to handle relative paths
2 parents 6d775e4 + 324797d commit 5df41d2

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

crates/gitbutler-project/src/project.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,20 @@ impl Project {
121121
/// Finds an existing project by its path. Errors out if not found.
122122
pub fn find_by_path(path: &Path) -> anyhow::Result<Project> {
123123
let projects = crate::list()?;
124+
let resolved_path = if path.is_relative() {
125+
path.canonicalize().context("Failed to canonicalize path")?
126+
} else {
127+
path.to_path_buf()
128+
};
124129
let project = projects
125130
.into_iter()
126-
.find(|p| p.path == path)
131+
.find(|p| {
132+
// Canonicalize project path for comparison
133+
match p.path.canonicalize() {
134+
Ok(proj_canon) => proj_canon == resolved_path,
135+
Err(_) => false,
136+
}
137+
})
127138
.context("No project found with the given path")?;
128139
Ok(project)
129140
}

0 commit comments

Comments
 (0)