(git: &GitRepository)
| 2891 | } |
| 2892 | |
| 2893 | pub(crate) fn require_clean_git_worktree(git: &GitRepository) -> CliResult<()> { |
| 2894 | let index = git |
| 2895 | .index() |
| 2896 | .map_err(|error| git_error(format!("cannot read Git index: {error}")))?; |
| 2897 | if index.has_conflicts() { |
| 2898 | return Err(git_error("Git index contains unresolved conflicts")); |
| 2899 | } |
| 2900 | |
| 2901 | let mut options = GitStatusOptions::new(); |
| 2902 | options |
| 2903 | .include_untracked(false) |
| 2904 | .recurse_untracked_dirs(false); |
| 2905 | let statuses = git |
| 2906 | .statuses(Some(&mut options)) |
| 2907 | .map_err(|error| git_error(format!("cannot inspect Git status: {error}")))?; |
| 2908 | if statuses.iter().any(|entry| tracked_delta(entry.status())) { |
| 2909 | return Err(git_error( |
| 2910 | "Git has staged or unstaged changes to tracked paths", |
| 2911 | )); |
| 2912 | } |
| 2913 | Ok(()) |
| 2914 | } |
| 2915 | |
| 2916 | fn require_matching_clean_workspaces<'repo>( |
| 2917 | repo: &Repository, |
no test coverage detected