Skip to content

Commit caf3c15

Browse files
committed
Enhance GitActionsControl to handle merge conflicts
- Add support for detecting merge conflicts in Git status. - Update action disabling logic to provide user feedback when conflicts exist. - Introduce a new icon for conflict resolution actions in the UI.
1 parent 4599196 commit caf3c15

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

apps/web/src/components/GitActionsControl.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ import type {
66
} from "@okcode/contracts";
77
import { useIsMutating, useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
88
import { useCallback, useEffect, useEffectEvent, useMemo, useRef, useState } from "react";
9-
import { ChevronDownIcon, CloudUploadIcon, GitCommitIcon, InfoIcon } from "lucide-react";
9+
import {
10+
ChevronDownIcon,
11+
CircleAlertIcon,
12+
CloudUploadIcon,
13+
GitCommitIcon,
14+
InfoIcon,
15+
} from "lucide-react";
1016
import { GitHubIcon } from "./Icons";
1117
import {
1218
buildGitActionProgressStages,
@@ -130,11 +136,15 @@ function getMenuActionDisabledReason({
130136

131137
const hasBranch = gitStatus.branch !== null;
132138
const hasChanges = gitStatus.hasWorkingTreeChanges;
139+
const hasConflicts = gitStatus.hasConflicts;
133140
const hasOpenPr = gitStatus.pr?.state === "open";
134141
const isAhead = gitStatus.aheadCount > 0;
135142
const isBehind = gitStatus.behindCount > 0;
136143

137144
if (item.id === "commit") {
145+
if (hasConflicts) {
146+
return "Resolve merge conflicts before committing.";
147+
}
138148
if (!hasChanges) {
139149
return "Worktree is clean. Make changes before committing.";
140150
}
@@ -145,6 +155,9 @@ function getMenuActionDisabledReason({
145155
if (!hasBranch) {
146156
return "Detached HEAD: checkout a branch before pushing.";
147157
}
158+
if (hasConflicts) {
159+
return "Resolve merge conflicts before pushing.";
160+
}
148161
if (hasChanges) {
149162
return "Commit or stash local changes before pushing.";
150163
}
@@ -166,6 +179,9 @@ function getMenuActionDisabledReason({
166179
if (!hasBranch) {
167180
return "Detached HEAD: checkout a branch before creating a PR.";
168181
}
182+
if (hasConflicts) {
183+
return "Resolve merge conflicts before creating a PR.";
184+
}
169185
if (hasChanges) {
170186
return "Commit local changes before creating a PR.";
171187
}
@@ -195,6 +211,9 @@ function GitQuickActionIcon({ quickAction }: { quickAction: GitQuickAction }) {
195211
const iconClassName = "size-3.5";
196212
if (quickAction.kind === "open_pr") return <GitHubIcon className={iconClassName} />;
197213
if (quickAction.kind === "run_pull") return <InfoIcon className={iconClassName} />;
214+
if (quickAction.kind === "resolve_conflicts") {
215+
return <CircleAlertIcon className={iconClassName} />;
216+
}
198217
if (quickAction.kind === "run_action") {
199218
if (quickAction.action === "commit") return <GitCommitIcon className={iconClassName} />;
200219
if (quickAction.action === "commit_push") return <CloudUploadIcon className={iconClassName} />;

0 commit comments

Comments
 (0)