diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 12:41:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 12:41:41 +0000 |
commit | 10ee2acdd26a7f1298c6f6d6b7af9b469fe29b87 (patch) | |
tree | bdffd5d80c26cf4a7a518281a204be1ace85b4c1 /vendor/gix/src/repository/state.rs | |
parent | Releasing progress-linux version 1.70.0+dfsg1-9~progress7.99u1. (diff) | |
download | rustc-10ee2acdd26a7f1298c6f6d6b7af9b469fe29b87.tar.xz rustc-10ee2acdd26a7f1298c6f6d6b7af9b469fe29b87.zip |
Merging upstream version 1.70.0+dfsg2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/gix/src/repository/state.rs')
-rw-r--r-- | vendor/gix/src/repository/state.rs | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/vendor/gix/src/repository/state.rs b/vendor/gix/src/repository/state.rs new file mode 100644 index 000000000..4034fe349 --- /dev/null +++ b/vendor/gix/src/repository/state.rs @@ -0,0 +1,44 @@ +use crate::state; + +impl crate::Repository { + /// Returns the status of an in progress operation on a repository or [`None`] + /// if no operation is currently in progress. + /// + /// Note to be confused with the repositories 'status'. + pub fn state(&self) -> Option<state::InProgress> { + let git_dir = self.path(); + + // This is modeled on the logic from wt_status_get_state in git's wt-status.c and + // ps1 from gix-prompt.sh. + + if git_dir.join("rebase-apply/applying").is_file() { + Some(state::InProgress::ApplyMailbox) + } else if git_dir.join("rebase-apply/rebasing").is_file() { + Some(state::InProgress::Rebase) + } else if git_dir.join("rebase-apply").is_dir() { + Some(state::InProgress::ApplyMailboxRebase) + } else if git_dir.join("rebase-merge/interactive").is_file() { + Some(state::InProgress::RebaseInteractive) + } else if git_dir.join("rebase-merge").is_dir() { + Some(state::InProgress::Rebase) + } else if git_dir.join("CHERRY_PICK_HEAD").is_file() { + if git_dir.join("sequencer/todo").is_file() { + Some(state::InProgress::CherryPickSequence) + } else { + Some(state::InProgress::CherryPick) + } + } else if git_dir.join("MERGE_HEAD").is_file() { + Some(state::InProgress::Merge) + } else if git_dir.join("BISECT_LOG").is_file() { + Some(state::InProgress::Bisect) + } else if git_dir.join("REVERT_HEAD").is_file() { + if git_dir.join("sequencer/todo").is_file() { + Some(state::InProgress::RevertSequence) + } else { + Some(state::InProgress::Revert) + } + } else { + None + } + } +} |