Merge branch 'main' of github.com:getpaseo/paseo

This commit is contained in:
Mohamed Boudra
2026-05-24 12:59:53 +07:00
3 changed files with 58 additions and 7 deletions
+1 -1
View File
@@ -1 +1 @@
sha256-HyLHXzKmhLq96mttcBc38s1VSTbxQ3qUL+/K6dyghL4=
sha256-H18zIrryRN+tfQA68vfbWHNMN1mOxhO4PAWcZ4yuNSc=
@@ -493,6 +493,53 @@ const x = 1;
expect(status.aheadOfOrigin).toBeNull();
});
it("does not report full history as unpushed for fresh no-track Paseo worktrees", async () => {
setupRemoteTrackingMain(repoDir, tempDir);
commitFile(repoDir, "second.txt", "second\n", "second commit");
execFileSync("git", ["push"], { cwd: repoDir });
const worktree = await createLegacyWorktreeForTest({
branchName: "fresh-feature",
cwd: repoDir,
baseBranch: "main",
worktreeSlug: "fresh-feature",
paseoHome,
});
const status = await getCheckoutStatus(worktree.worktreePath, { paseoHome });
expect(status).toMatchObject({
isGit: true,
isPaseoOwnedWorktree: true,
baseRef: "main",
aheadBehind: { ahead: 0, behind: 0 },
aheadOfOrigin: 0,
});
});
it("reports local-only worktree commits as unpushed relative to base", async () => {
setupRemoteTrackingMain(repoDir, tempDir);
commitFile(repoDir, "second.txt", "second\n", "second commit");
execFileSync("git", ["push"], { cwd: repoDir });
const worktree = await createLegacyWorktreeForTest({
branchName: "fresh-feature",
cwd: repoDir,
baseBranch: "main",
worktreeSlug: "fresh-feature",
paseoHome,
});
commitFile(worktree.worktreePath, "feature.txt", "feature\n", "feature commit");
const status = await getCheckoutStatus(worktree.worktreePath, { paseoHome });
expect(status).toMatchObject({
isGit: true,
isPaseoOwnedWorktree: true,
baseRef: "main",
aheadBehind: { ahead: 1, behind: 0 },
aheadOfOrigin: 1,
});
});
it("does not report incoming additions when the base branch is behind its remote", async () => {
const { cloneDir } = setupRemoteTrackingMain(repoDir, tempDir);
commitFile(cloneDir, "file.txt", "remote one\nremote two\n", "remote update");
+10 -6
View File
@@ -1268,6 +1268,7 @@ async function getAheadBehind(
async function getAheadOfOrigin(
cwd: string,
currentBranch: string,
baseRef: string | null,
context?: CheckoutContext,
): Promise<number | null> {
if (!currentBranch) {
@@ -1286,12 +1287,15 @@ async function getAheadOfOrigin(
if (trackedOriginBranch) {
return null;
}
if (!baseRef || normalizeLocalBranchRefName(baseRef) === currentBranch) {
return null;
}
try {
const { stdout } = await runGitCommand(["rev-list", "--count", currentBranch], {
cwd,
envOverlay: READ_ONLY_GIT_ENV,
logger: context?.logger,
});
const comparisonBaseRef = await resolveBestComparisonBaseRef(cwd, baseRef, context);
const { stdout } = await runGitCommand(
["rev-list", "--count", `${comparisonBaseRef}..${currentBranch}`],
{ cwd, envOverlay: READ_ONLY_GIT_ENV, logger: context?.logger },
);
const count = Number.parseInt(stdout.trim(), 10);
return Number.isNaN(count) ? null : count;
} catch {
@@ -1503,7 +1507,7 @@ export async function getCheckoutStatus(
? getAheadBehind(cwd, baseRef, currentBranch, context)
: Promise.resolve(null),
hasRemote && currentBranch
? getAheadOfOrigin(cwd, currentBranch, context)
? getAheadOfOrigin(cwd, currentBranch, baseRef, context)
: Promise.resolve(null),
hasRemote && currentBranch
? getBehindOfOrigin(cwd, currentBranch, context)