Commit any uncommitted changes in the repository. This first commits changes in any submodules, then commits in the superproject. Returns any non-fatal warnings encountered during the commit process.
(
&self,
repo_path: &Path,
message: &str,
)
| 502 | /// This first commits changes in any submodules, then commits in the superproject. |
| 503 | /// Returns any non-fatal warnings encountered during the commit process. |
| 504 | pub async fn commit_changes( |
| 505 | &self, |
| 506 | repo_path: &Path, |
| 507 | message: &str, |
| 508 | ) -> Result<Vec<String>, String> { |
| 509 | let mut warnings = Vec::new(); |
| 510 | |
| 511 | // First commit any uncommitted changes in submodules |
| 512 | // This must happen before the superproject commit so the submodule pointers are updated |
| 513 | match self.commit_submodule_changes(repo_path, message).await { |
| 514 | Ok((_committed, sub_warnings)) => warnings.extend(sub_warnings), |
| 515 | Err(e) => { |
| 516 | warnings.push(format!("Failed to commit submodule changes: {e}")); |
| 517 | // Continue with superproject commit even if submodule commits fail |
| 518 | } |
| 519 | } |
| 520 | |
| 521 | // Check if there are any changes to commit |
| 522 | let status_output = git_operations::get_status(repo_path).await?; |
| 523 | |
| 524 | if status_output.trim().is_empty() { |
| 525 | return Ok(warnings); |
| 526 | } |
| 527 | |
| 528 | // Add all changes |
| 529 | git_operations::add_all(repo_path).await?; |
| 530 | |
| 531 | // Commit changes |
| 532 | git_operations::commit(repo_path, message).await?; |
| 533 | |
| 534 | Ok(warnings) |
| 535 | } |
| 536 | |
| 537 | /// Set git-town parent branch configuration |
| 538 | /// |