git_graph: Add built-in branch and commit actions to the context menu#60370
Open
sergiooroman wants to merge 6 commits into
Open
git_graph: Add built-in branch and commit actions to the context menu#60370sergiooroman wants to merge 6 commits into
sergiooroman wants to merge 6 commits into
Conversation
Adds checkout, merge, create branch, and delete branch entries for branch refs, plus detached checkout, cherry-pick, revert, and create branch entries for commits, to the Git Graph context menu. Branch operations use the existing Repository methods; operations without native backend support run as one-shot terminal tasks through the same infrastructure as custom Git commands. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
We require contributors to sign our Contributor License Agreement, and we don't have @sergiooroman on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'. |
Replaces the terminal-task implementation with native GitRepository operations, including proto messages and collab forwarding so they work in shared and remote projects. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Adds Create Tag on branches and commits, Check Out Tag and Delete Tag on tag labels, and a Squash Merge variant alongside the regular merge, with the corresponding native backend operations and proto messages. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
An optional message field creates an annotated tag when filled in and a lightweight tag when left empty. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Ref changes like tag creation or deletion emit no repository event, so the graph would otherwise wait indefinitely (or on watcher latency) to reflect an operation it initiated itself. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Refreshing the view alone re-read the repository's cached graph data, so ref changes that emit no repository event (such as tag edits) still showed stale entries. Drop the repository's graph cache before rebuilding. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Objective
The Git Graph context menu currently only offers read-only entries (View Commit, Copy SHA / Ref Name / Tag) plus user-defined custom commands. Common Git operations — checking out a branch, merging it, creating a branch from a commit, deleting a branch, cherry-picking — require leaving the graph, even though the graph is the natural place to perform them (as in VS Code's Git Graph extension, Fork, or Sublime Merge).
Solution
Adds built-in actions to the Git Graph context menu, all running through the native git backend (no terminal round-trip), so they work in remote projects too and refresh Zed's Git state as usual.
Right-clicking a branch label:
Repository::change_branch(which already creates a local tracking branch for remote refs); disabled for the checked-out branch.<current branch>/ Squash Merge into<current branch>— new nativemergeoperation (git merge --no-edit <ref>/git merge --squash <ref>); disabled when the clicked ref is the checked-out branch. A squash merge stages the changes so they can be reviewed and committed from the Git Panel.Repository::create_branch(creates and switches, matching the branch picker's behavior) or the new nativecreate_tag. The tag modal has an optional message field: filled in creates an annotated tag, empty creates a lightweight tag.Repository::delete_branch, reusing the branch picker's force-delete fallback for unmerged branches. Remote-ness is resolved from the live branch list rather than guessed from the ref string.Right-clicking a commit row:
checkout_commitoperation (git checkout --detach <sha>).cherry_pickoperation.revertoperation (git revert --no-edit <sha>).Right-clicking a tag label: Check Out Tag (detached), Create Branch from Here…, and Delete Tag… (with confirmation).
Backend changes:
GitRepositorygainsmerge(with a squash flag),cherry_pick,revert,checkout_commit,create_tag, anddelete_tag, implemented forRealGitRepositoryandFakeGitRepository.GitMerge,GitCherryPick,GitRevert,GitCheckoutCommit,GitCreateTag, andGitDeleteTagproto messages (462–467), withGitStorehandlers and collab forwarding, so the operations work in shared/remote projects like the existing branch operations.Repository(git_store) exposes the operations following the samesend_joblocal/remote pattern aschange_branch.Failure cases (e.g. a merge or cherry-pick with conflicts) surface through the standard git error toast with View Log, and conflicts can then be resolved from the Git Panel as usual.
User-defined custom commands keep working and stay in their own section below the built-in entries. Docs: added a "Git Graph" section to
docs/src/git.md.Testing
test_merge_cherry_pick_revert_and_checkout_commitincrates/gitexercising the new backend operations end to end, including squash merge staging, lightweight vs. annotated tag creation, and tag deletion.test_checkout_commit_detaches_headincrates/git_uicovering the graph-level action against the fake backend.git_uitest suite passes (cargo test -p git_ui --lib), clippy clean with--deny warningson all touched crates.Self-Review Checklist:
Release Notes:
🤖 Generated with Claude Code