-
-
Notifications
You must be signed in to change notification settings - Fork 401
Add Repository::in_progress_operation() #382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
c2f66e4
First pass at Repository::in_progress_state()
56038ed
Tweak the naming and comments a bit
172b464
in_progress_operation now returns an Option
499c811
Add a few tests for good measure.
4086335
Merge branch 'main' into repo-status
bb18a13
Pass version appropriate rebase flags to git.
a5406b5
Make clippy happier.
5c162e0
Fix the GNU sed detection so it works where /usr/bin/sed is GNU.
ac3c8c7
Take a couple more steps to appease the CI gods.
475e7d1
Let's try not parsing the git version.
53c22ee
repo_path -> git_dir
0eb2372
Merge branch 'main' into repo-status
cf19a18
Print out some human readable text if GNU sed cannot be found.
463a705
Clean up the error message and comments.
8122c5c
Merge branch 'main' into repo-status
da8059c
RepositoryState: remove unused variant
9679d6b
Merge branch 'main' into repo-status
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,6 +78,8 @@ mod location; | |
|
|
||
| mod snapshots; | ||
|
|
||
| mod state; | ||
|
|
||
| mod impls; | ||
|
|
||
| mod cache; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| use crate::RepositoryState; | ||
|
|
||
| impl crate::Repository { | ||
| /// Returns the status of an in progress operation on a repository or [`RepositoryState::None`] | ||
| /// if nothing is happening. | ||
| pub fn in_progress_operation(&self) -> RepositoryState { | ||
| let repo_path = self.path(); | ||
inferiorhumanorgans marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| // This is modeled on the logic from wt_status_get_state in git's wt-status.c and | ||
| // ps1 from git-prompt.sh. | ||
|
|
||
| if repo_path.join("rebase-apply/applying").is_file() { | ||
| return RepositoryState::ApplyMailbox; | ||
| } else if repo_path.join("rebase-apply/rebasing").is_file() { | ||
| return RepositoryState::Rebase; | ||
| } else if repo_path.join("rebase-apply").is_dir() { | ||
| return RepositoryState::ApplyMailboxRebase; | ||
| } else if repo_path.join("rebase-merge/interactive").is_file() { | ||
| return RepositoryState::RebaseInteractive; | ||
| } else if repo_path.join("rebase-merge").is_dir() { | ||
| return RepositoryState::Rebase; | ||
| } else if repo_path.join("CHERRY_PICK_HEAD").is_file() { | ||
| if repo_path.join("todo").is_file() { | ||
| return RepositoryState::CherryPickSequence; | ||
| } else { | ||
| return RepositoryState::CherryPick; | ||
| } | ||
| } else if repo_path.join("MERGE_HEAD").is_file() { | ||
| return RepositoryState::Merge; | ||
| } else if repo_path.join("BISECT_LOG").is_file() { | ||
| return RepositoryState::Bisect; | ||
| } else if repo_path.join("REVERT_HEAD").is_file() { | ||
| if repo_path.join("todo").is_file() { | ||
| return RepositoryState::RevertSequence; | ||
| } else { | ||
| return RepositoryState::Revert; | ||
| } | ||
| } else { | ||
| return RepositoryState::None; | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.