-
-
Notifications
You must be signed in to change notification settings - Fork 12
Add git worktree
support actions and :x
variants to rebase
actions
#158
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
Conversation
WalkthroughThe changes introduce new and extended support for Git worktree operations in the Denops Gin plugin. Branch deletion and move logic now conditionally handle worktrees, and a new module enables creating worktrees (including forced and orphaned variants). The branch edit command is updated to initialize the new worktree action. Additionally, rebase commands are extended to optionally execute a user-specified command after completion. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Denops
participant GinPlugin
participant Git
User->>Denops: Invoke branch delete/move command
Denops->>GinPlugin: Dispatch action with Candidate
alt Candidate has worktree
GinPlugin->>Git: worktree remove/move <worktree>
else Candidate has no worktree
GinPlugin->>Git: branch -d/-D or branch --move <branch>
end
sequenceDiagram
participant User
participant Denops
participant GinPlugin
participant Git
User->>Denops: Invoke worktree new/force/orphan command
Denops->>GinPlugin: Dispatch worktree_new action
GinPlugin->>User: Prompt for worktree path
User->>GinPlugin: Provide path (or cancel)
alt User provides path
GinPlugin->>Git: worktree add [--force|--orphan] <path>
else User cancels
GinPlugin->>User: Echo "Canceled"
end
sequenceDiagram
participant User
participant Denops
participant GinPlugin
participant Git
User->>Denops: Invoke rebase:x or rebase:i:x command
Denops->>GinPlugin: Dispatch rebase action with execute flag
GinPlugin->>User: Prompt for post-rebase command
alt User provides command
GinPlugin->>Git: rebase ... -x <command>
else User cancels or empty
GinPlugin->>User: Echo "Canceled"
end
GinPlugin->>Denops: silent checktime
Possibly related PRs
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #158 +/- ##
=======================================
Coverage 60.30% 60.30%
=======================================
Files 17 17
Lines 912 912
Branches 120 120
=======================================
Hits 550 550
Misses 362 362 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
denops/gin/action/worktree_new.ts (1)
66-87
: Fix parameter type inconsistency.The
_gatherCandidates
parameter usesGatherCandidates<unknown>
instead ofGatherCandidates<Candidate>
for consistency with the other functions and the exportedCandidate
type.- _gatherCandidates: GatherCandidates<unknown>, + _gatherCandidates: GatherCandidates<Candidate>,
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
denops/gin/action/branch_delete.ts
(2 hunks)denops/gin/action/branch_move.ts
(2 hunks)denops/gin/action/worktree_new.ts
(1 hunks)denops/gin/command/branch/edit.ts
(2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
denops/gin/action/branch_move.ts (1)
denops/gin/action/branch_delete.ts (1)
Candidate
(5-7)
⏰ Context from checks skipped due to timeout of 90000ms (6)
- GitHub Check: test (windows-latest, 1.45.0, v9.1.0448, v0.10.0)
- GitHub Check: test (macos-latest, 1.x, v9.1.0448, v0.10.0)
- GitHub Check: test (macos-latest, 1.45.0, v9.1.0448, v0.10.0)
- GitHub Check: test (ubuntu-latest, 1.45.0, v9.1.0448, v0.10.0)
- GitHub Check: test (windows-latest, 1.x, v9.1.0448, v0.10.0)
- GitHub Check: test (ubuntu-latest, 1.x, v9.1.0448, v0.10.0)
🔇 Additional comments (7)
denops/gin/action/worktree_new.ts (2)
1-36
: LGTM! Well-structured worktree action initialization.The implementation follows Denops patterns correctly with proper batch operations, command registration, and clean separation of concerns for different worktree creation modes.
38-64
: LGTM! Proper implementation of worktree creation logic.The function correctly handles candidate gathering, user input with sensible defaults, cancellation handling, and Git command dispatch with conditional force flag support.
denops/gin/command/branch/edit.ts (2)
22-22
: LGTM! Clean import addition.The import follows the established pattern and naming conventions.
75-75
: LGTM! Proper integration of worktree action.The initialization call is correctly placed within the batch operation and uses consistent parameters with other action initializations.
denops/gin/action/branch_delete.ts (2)
7-7
: LGTM! Appropriate type extension for worktree support.The optional
worktree
property correctly extends the local/alias branch candidate type to support worktree operations.
53-65
: LGTM! Correct worktree-aware deletion logic.The conditional logic properly handles worktree removal vs branch deletion, with appropriate Git command construction for both scenarios.
denops/gin/action/branch_move.ts (1)
6-6
: LGTM! Clean type definition for worktree support.The
Candidate
type appropriately includes the optionalworktree
property for move operations.
c41c089
to
3d26c2c
Compare
git worktree
supportgit worktree
support actions and :x
variants to rebase
actions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
denops/gin/action/rebase.ts (2)
57-57
: Consider extracting duplicate logic into a helper function.The execute command logic is duplicated between
doRebase
anddoRebaseInteractive
. While the implementation is correct, extracting this into a shared helper function would improve maintainability.+async function getExecuteCommand(denops: Denops): Promise<string | null> { + const cmd = await helper.input(denops, { + prompt: "Execute command after rebase: ", + }) ?? ""; + await denops.cmd('redraw | echo ""'); + if (!cmd) { + await helper.echoerr(denops, "Cancelled"); + return null; + } + return cmd; +} async function doRebase( denops: Denops, bufnr: number, range: Range, gatherCandidates: GatherCandidates<Candidate>, execute?: boolean, ): Promise<void> { const xs = await gatherCandidates(denops, bufnr, range); const x = xs.at(0); if (!x) { return; } const args = ["rebase", x.commit]; if (execute) { - const cmd = await helper.input(denops, { - prompt: "Execute command after rebase: ", - }) ?? ""; - await denops.cmd('redraw | echo ""'); - if (!cmd) { - await helper.echoerr(denops, "Cancelled"); + const cmd = await getExecuteCommand(denops); + if (!cmd) { return; } args.push("-x", cmd); } await denops.dispatch("gin", "command", "", args);Also applies to: 64-76
87-87
: Same duplication issue applies here.The interactive rebase function has the same duplicated execute command logic. The implementation is correct but would benefit from the same helper function extraction suggested for
doRebase
.async function doRebaseInteractive( denops: Denops, bufnr: number, range: Range, gatherCandidates: GatherCandidates<Candidate>, execute?: boolean, ): Promise<void> { const xs = await gatherCandidates(denops, bufnr, range); const x = xs.at(0); if (!x) { return; } const args = [ "rebase", "--interactive", x.commit, ]; if (execute) { - const cmd = await helper.input(denops, { - prompt: "Execute command after rebase: ", - }) ?? ""; - await denops.cmd('redraw | echo ""'); - if (!cmd) { - await helper.echoerr(denops, "Cancelled"); + const cmd = await getExecuteCommand(denops); + if (!cmd) { return; } args.push("-x", cmd); }Also applies to: 94-109
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
denops/gin/action/branch_delete.ts
(2 hunks)denops/gin/action/branch_move.ts
(2 hunks)denops/gin/action/branch_new.ts
(2 hunks)denops/gin/action/rebase.ts
(3 hunks)denops/gin/action/worktree_new.ts
(1 hunks)denops/gin/command/branch/edit.ts
(2 hunks)
✅ Files skipped from review due to trivial changes (1)
- denops/gin/action/branch_new.ts
🚧 Files skipped from review as they are similar to previous changes (4)
- denops/gin/command/branch/edit.ts
- denops/gin/action/branch_delete.ts
- denops/gin/action/branch_move.ts
- denops/gin/action/worktree_new.ts
🧰 Additional context used
🧬 Code Graph Analysis (1)
denops/gin/action/rebase.ts (3)
denops/gin/action/core.ts (1)
define
(89-114)denops/gin/git/executor.ts (1)
execute
(43-109)denops/gin/git/process.ts (1)
execute
(42-56)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: test (macos-latest, 1.x, v9.1.0448, v0.10.0)
🔇 Additional comments (3)
denops/gin/action/rebase.ts (3)
21-27
: LGTM! New rebase action with command execution.The new "rebase:x" action definition correctly passes the execute flag to enable command execution after rebase.
35-41
: LGTM! New interactive rebase action with command execution.The new "rebase:i:x" action definition correctly passes the execute flag to enable command execution after interactive rebase.
110-119
: Good handling of async dispatch for interactive rebase.The implementation correctly avoids awaiting the dispatch call to prevent Vim from freezing, and properly handles errors and cleanup. The comment explains the reasoning well.
Summary by CodeRabbit