Skip to content

Commit

Permalink
Direct context menu checkouts to use correct parent branch on staged …
Browse files Browse the repository at this point in the history
…GitNode
  • Loading branch information
nelsonni committed Nov 2, 2023
1 parent c655211 commit b8512d3
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/renderer/src/components/GitGraph/ContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,18 +163,20 @@ const ContextMenu = ({

const actions: Action[] = [
...node.data.parents
.map(parent => repoBranches.find(b => b.head === parent))
.map(parent =>
repoBranches.find(b => b.head === parent && `${b.scope}/${b.ref}*` === node.data.oid),
)
.filter(isDefined)
.map(branch => ({
icon: <GitBranch />,
name: `Checkout ${branch.scope}/${branch.ref}`,
disabled: !node.data.staged,
disabled: !node.data.staged, // only show parents when staged
onClick: () => checkout({id: branch.id}),
})),
...node.data.heads.map(branch => ({
icon: <GitBranch />,
name: `Checkout ${branches[branch]?.scope}/${branches[branch]?.ref}`,
disabled: node.data.staged,
disabled: node.data.staged, // only show when not staged
onClick: () => checkout({id: branch}),
})),
{
Expand Down

0 comments on commit b8512d3

Please sign in to comment.