Repository navigation
feat: stage, unstage, discard and go from file to file by keys, and clone or create from the palette - #59
Merged
Conversation
…lone or create from the palette
Merged
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What this changes
With a diff in view, the keyboard now does what its buttons and the panel on the right do:
Stage, unstage and discard act on the lines you picked, or on the whole file while you picked none, so an untracked file can be staged or deleted from its diff too. Next and previous go through the files in the order of the panel on the right: the unstaged and then the staged changes (conflicted files open to be resolved, so they are skipped), or the files of the selected commit. With no file in view, Ctrl+Down opens the first one, so from the graph you can pick a commit with the arrows and step through its files.
Once a file in the working tree has nothing left on its side, as when you stage it, the next file of that list takes its place instead of an empty "No changes" diff; when there is none, the diff closes. That makes going through the changes and staging them one by one a matter of reading and pressing Ctrl+S.
The palette also lists these, by name ("Stage file", "Stage 2 lines", "Discard file…", "Next file", "Back to the graph"), and the start screen's "Clone a repository…" and "Create a repository…", which open its dialog from any tab. The buttons that stage or discard picked lines show their key in a tooltip.
Next and previous file are not on Alt and the arrows: labwc, and other window managers, move the window with those.
How it is built:
diff::commandsnames what can be done with the file in view, by the same verbs as the buttons;details::discardnow takes the diff it is about, so the panel and the keyboard ask the same question.Workspace::changeslists the changed files with their diffs, once, for the panel, for next and previous (Workspace::listed) and for finding the file that takes the place of one with no changes left (Workspace::reread, out ofpoll).Action::NewRepo, like the palette.This is part 2 of "Keyboard", the last part, on the roadmap.
How it is tested
stage_unstage_and_discard_the_file_in_view_by_keys: with two changed files and an untracked one, Ctrl+Down and Ctrl+Up go through them in the panel's order; Ctrl+S stages the file in view and the next one takes its place; with a line picked (clicked), Ctrl+S stages only that line and the file stays; Ctrl+Backspace asks before it discards; staging the untracked file leaves nothing unstaged and the diff closes; Ctrl+U unstages a staged file and the next staged one shows. It fails without the next file taking the place.the_keyboard_goes_through_a_commit_s_files_and_back_to_the_graph: Ctrl+Down from the graph opens the selected commit's first file and stops at the last; a commit's file has nothing to stage in the palette and "Previous file" is off on the first; "Back to the graph" from the palette; "clone" and "create" open their dialogs on the start screen.The rebase and search tests still pass, and fail when the keyboard takes Escape from the views (checked).
On the desktop (labwc): stepping through four changed files, staging a file and a single line, the discard question, the palette with its shortcuts, clone from a repository tab, and a commit's files.
cargo fmt --all,cargo clippy --workspace --all-targets -- -D warningsandcargo test --workspacepassIt adds as little code as the change needs, and removes what it makes unnecessary
Nothing in it comes from GitKraken or another closed-source client (see CONTRIBUTING.md)