Commit any uncommitted changes in submodules before the superproject commit. This ensures submodule changes are captured and the superproject pointer is updated. Returns a tuple of (committed submodule paths, non-fatal warnings).
(
&self,
repo_path: &Path,
message: &str,
)
| 435 | /// This ensures submodule changes are captured and the superproject pointer is updated. |
| 436 | /// Returns a tuple of (committed submodule paths, non-fatal warnings). |
| 437 | async fn commit_submodule_changes( |
| 438 | &self, |
| 439 | repo_path: &Path, |
| 440 | message: &str, |
| 441 | ) -> Result<(Vec<String>, Vec<String>), String> { |
| 442 | let submodules = self.parse_gitmodules(repo_path).await?; |
| 443 | |
| 444 | if submodules.is_empty() { |
| 445 | return Ok((Vec::new(), Vec::new())); |
| 446 | } |
| 447 | |
| 448 | let mut committed_submodules = Vec::new(); |
| 449 | let mut warnings = Vec::new(); |
| 450 | |
| 451 | for submodule in submodules { |
| 452 | let submodule_path = repo_path.join(&submodule.path); |
| 453 | |
| 454 | // Check if the submodule is a valid git repository |
| 455 | if !git_operations::is_git_repository(&submodule_path) |
| 456 | .await |
| 457 | .unwrap_or(false) |
| 458 | { |
| 459 | continue; |
| 460 | } |
| 461 | |
| 462 | // Check if submodule has uncommitted changes |
| 463 | let status_output = match git_operations::get_status(&submodule_path).await { |
| 464 | Ok(output) => output, |
| 465 | Err(e) => { |
| 466 | warnings.push(format!( |
| 467 | "Failed to get status for submodule '{}': {}", |
| 468 | submodule.path, e |
| 469 | )); |
| 470 | continue; |
| 471 | } |
| 472 | }; |
| 473 | |
| 474 | if status_output.trim().is_empty() { |
| 475 | continue; |
| 476 | } |
| 477 | |
| 478 | // Add and commit changes in the submodule |
| 479 | if let Err(e) = git_operations::add_all(&submodule_path).await { |
| 480 | warnings.push(format!( |
| 481 | "Failed to stage changes in submodule '{}': {}", |
| 482 | submodule.path, e |
| 483 | )); |
| 484 | continue; |
| 485 | } |
| 486 | |
| 487 | if let Err(e) = git_operations::commit(&submodule_path, message).await { |
| 488 | warnings.push(format!( |
| 489 | "Failed to commit changes in submodule '{}': {}", |
| 490 | submodule.path, e |
| 491 | )); |
| 492 | continue; |
| 493 | } |
| 494 |
no test coverage detected