Skip to content

Commit 47c7fb3

Browse files
committed
Avoid claiming we would move something even though we won't (in 'organize')
The check to see if a repository is already in place was done only in 'execute' mode.
1 parent 1ccfdcd commit 47c7fb3

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

gitoxide-core/src/organize.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -154,23 +154,24 @@ fn handle(
154154
.ok_or_else(|| anyhow::Error::msg(format!("Remote URLs must have host names: {}", url)))?,
155155
)
156156
.join(to_relative(git_url::expand_path(None, url.path.as_bstr())?));
157+
158+
if git_workdir.canonicalize()? == destination.canonicalize()? {
159+
progress.info(format!(
160+
"Skipping {:?} as it is in the correct spot",
161+
git_workdir.display()
162+
));
163+
return Ok(());
164+
}
157165
match mode {
158166
Mode::Simulate => progress.info(format!(
159167
"WOULD move {} to {}",
160168
git_workdir.display(),
161169
destination.display()
162170
)),
163171
Mode::Execute => {
164-
if git_workdir.canonicalize()? == destination {
165-
progress.info(format!(
166-
"Skipping {:?} as it is in the correct spot",
167-
git_workdir.display()
168-
));
169-
} else {
170-
std::fs::create_dir_all(destination.parent().expect("repo destination is not the root"))?;
171-
progress.done(format!("Moving {} to {}", git_workdir.display(), destination.display()));
172-
std::fs::rename(git_workdir, &destination)?;
173-
}
172+
std::fs::create_dir_all(destination.parent().expect("repo destination is not the root"))?;
173+
progress.done(format!("Moving {} to {}", git_workdir.display(), destination.display()));
174+
std::fs::rename(git_workdir, &destination)?;
174175
}
175176
}
176177
Ok(())

0 commit comments

Comments
 (0)