mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-23 14:01:37 +00:00
Refactor git index refresh logic in syncback
- Simplified the `refresh_git_index` function by removing the retry mechanism and directly handling the exit code of the `git update-index --refresh` command. Now, it logs a warning only if the command fails to execute, improving clarity and reducing unnecessary complexity.
This commit is contained in:
parent
d4ae0820bc
commit
dddab62ea1
1 changed files with 9 additions and 39 deletions
|
|
@ -361,45 +361,15 @@ fn refresh_git_index(project_dir: &Path) {
|
||||||
|
|
||||||
if is_git_repo {
|
if is_git_repo {
|
||||||
log::info!("Refreshing git index...");
|
log::info!("Refreshing git index...");
|
||||||
let mut attempts = 0;
|
// Exit code 1 is normal - it just means files were refreshed.
|
||||||
loop {
|
// We only warn if git itself fails to run.
|
||||||
attempts += 1;
|
match Command::new("git")
|
||||||
let result = Command::new("git")
|
.args(["update-index", "--refresh", "-q"])
|
||||||
.args(["update-index", "--refresh"])
|
.current_dir(project_dir)
|
||||||
.current_dir(project_dir)
|
.status()
|
||||||
.stdout(Stdio::null())
|
{
|
||||||
.stderr(Stdio::null())
|
Ok(_) => log::info!("Git index refreshed."),
|
||||||
.status();
|
Err(e) => log::warn!("Failed to run git update-index --refresh: {}", e),
|
||||||
|
|
||||||
match result {
|
|
||||||
Ok(status) => {
|
|
||||||
if status.success() {
|
|
||||||
log::info!("Git index refreshed.");
|
|
||||||
break;
|
|
||||||
} else if attempts < 2 {
|
|
||||||
log::debug!(
|
|
||||||
"git update-index --refresh exited with: {}, retrying in 500ms...",
|
|
||||||
status
|
|
||||||
);
|
|
||||||
std::thread::sleep(std::time::Duration::from_millis(500));
|
|
||||||
} else {
|
|
||||||
log::warn!("git update-index --refresh exited with: {}", status);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
if attempts < 2 {
|
|
||||||
log::debug!(
|
|
||||||
"Failed to run git update-index --refresh: {}, retrying in 500ms...",
|
|
||||||
e
|
|
||||||
);
|
|
||||||
std::thread::sleep(std::time::Duration::from_millis(500));
|
|
||||||
} else {
|
|
||||||
log::warn!("Failed to run git update-index --refresh: {}", e);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log::debug!("Not a git repository, skipping index refresh.");
|
log::debug!("Not a git repository, skipping index refresh.");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue