Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions apps/desktop/src/lib/trpc/routers/changes/file-contents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const createFileContentsRouter = () => {
worktreePath: z.string(),
filePath: z.string(),
oldPath: z.string().optional(),
category: z.enum(["against-main", "committed", "staged", "unstaged"]),
category: z.enum(["against-base", "committed", "staged", "unstaged"]),
commitHash: z.string().optional(),
defaultBranch: z.string().optional(),
}),
Expand Down Expand Up @@ -57,7 +57,7 @@ export const createFileContentsRouter = () => {
});
};

type DiffCategory = "against-main" | "committed" | "staged" | "unstaged";
type DiffCategory = "against-base" | "committed" | "staged" | "unstaged";

interface FileVersions {
original: string;
Expand All @@ -74,8 +74,8 @@ async function getFileVersions(
commitHash?: string,
): Promise<FileVersions> {
switch (category) {
case "against-main":
return getAgainstMainVersions(git, filePath, originalPath, defaultBranch);
case "against-base":
return getAgainstBaseVersions(git, filePath, originalPath, defaultBranch);

case "committed":
if (!commitHash) {
Expand All @@ -91,7 +91,7 @@ async function getFileVersions(
}
}

async function getAgainstMainVersions(
async function getAgainstBaseVersions(
git: ReturnType<typeof simpleGit>,
filePath: string,
originalPath: string,
Expand Down
12 changes: 6 additions & 6 deletions apps/desktop/src/lib/trpc/routers/changes/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const createStatusRouter = () => {
return {
branch: parsed.branch,
defaultBranch,
againstMain: branchComparison.againstMain,
againstBase: branchComparison.againstBase,
commits: branchComparison.commits,
staged: parsed.staged,
unstaged: parsed.unstaged,
Expand Down Expand Up @@ -90,7 +90,7 @@ export const createStatusRouter = () => {

interface BranchComparison {
commits: GitChangesStatus["commits"];
againstMain: ChangedFile[];
againstBase: ChangedFile[];
ahead: number;
behind: number;
}
Expand All @@ -100,7 +100,7 @@ async function getBranchComparison(
defaultBranch: string,
): Promise<BranchComparison> {
let commits: GitChangesStatus["commits"] = [];
let againstMain: ChangedFile[] = [];
let againstBase: ChangedFile[] = [];
let ahead = 0;
let behind = 0;

Expand Down Expand Up @@ -128,17 +128,17 @@ async function getBranchComparison(
"--name-status",
`origin/${defaultBranch}...HEAD`,
]);
againstMain = parseNameStatus(nameStatus);
againstBase = parseNameStatus(nameStatus);

await applyNumstatToFiles(git, againstMain, [
await applyNumstatToFiles(git, againstBase, [
"diff",
"--numstat",
`origin/${defaultBranch}...HEAD`,
]);
}
} catch {}

return { commits, againstMain, ahead, behind };
return { commits, againstBase, ahead, behind };
}

async function applyUntrackedLineCount(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function ChangesContent() {

const selectedFileState = getSelectedFile(worktreePath || "");
const selectedFile = selectedFileState?.file ?? null;
const selectedCategory = selectedFileState?.category ?? "against-main";
const selectedCategory = selectedFileState?.category ?? "against-base";
const selectedCommitHash = selectedFileState?.commitHash ?? null;

const { data: branchData } = trpc.changes.getBranches.useQuery(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export function ChangesView() {

if (
!status ||
!status.againstMain ||
!status.againstBase ||
!status.commits ||
!status.staged ||
!status.unstaged ||
Expand All @@ -179,7 +179,7 @@ export function ChangesView() {
}

const hasChanges =
status.againstMain.length > 0 ||
status.againstBase.length > 0 ||
status.commits.length > 0 ||
status.staged.length > 0 ||
status.unstaged.length > 0 ||
Expand Down Expand Up @@ -225,19 +225,19 @@ export function ChangesView() {
</div>
) : (
<div className="flex-1 overflow-y-auto">
{/* Against Main */}
{/* Against base branch */}
<CategorySection
title="Against Main"
count={status.againstMain.length}
isExpanded={expandedSections["against-main"]}
onToggle={() => toggleSection("against-main")}
title={`Against ${effectiveBaseBranch}`}
count={status.againstBase.length}
isExpanded={expandedSections["against-base"]}
onToggle={() => toggleSection("against-base")}
>
<FileList
files={status.againstMain}
files={status.againstBase}
viewMode={fileListViewMode}
selectedFile={selectedFile}
selectedCommitHash={selectedCommitHash}
onFileSelect={(file) => handleFileSelect(file, "against-main")}
onFileSelect={(file) => handleFileSelect(file, "against-base")}
/>
</CategorySection>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ export function CategorySection({
) : (
<HiChevronRight className="w-4 h-4 text-muted-foreground shrink-0" />
)}
<span className="text-sm font-medium">{title}</span>
<span className="text-sm font-medium truncate text-ellipsis">
{title}
</span>
<span className="text-xs text-muted-foreground shrink-0">
({count})
</span>
Expand Down
4 changes: 2 additions & 2 deletions apps/desktop/src/renderer/stores/changes/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const initialState = {
viewMode: "side-by-side" as DiffViewMode,
fileListViewMode: "grouped" as FileListViewMode,
expandedSections: {
"against-main": true,
"against-base": true,
committed: true,
staged: true,
unstaged: true,
Expand All @@ -67,7 +67,7 @@ export const useChangesStore = create<ChangesState>()(
[worktreePath]: file
? {
file,
category: category ?? "against-main",
category: category ?? "against-base",
commitHash: commitHash ?? null,
}
: null,
Expand Down
4 changes: 2 additions & 2 deletions apps/desktop/src/shared/changes-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export type FileStatus =

/** Change categories for organizing the sidebar */
export type ChangeCategory =
| "against-main"
| "against-base"
| "committed"
| "staged"
| "unstaged";
Expand Down Expand Up @@ -41,7 +41,7 @@ export interface CommitInfo {
export interface GitChangesStatus {
branch: string;
defaultBranch: string; // Default branch (main/master)
againstMain: ChangedFile[]; // All files changed vs default branch
againstBase: ChangedFile[]; // All files changed vs base branch
commits: CommitInfo[]; // Individual commits on branch (not on default)
staged: ChangedFile[];
unstaged: ChangedFile[];
Expand Down
Loading