Merge branch 'main' of github.com:getpaseo/paseo
This commit is contained in:
+1
-1
@@ -1 +1 @@
|
|||||||
sha256-HyLHXzKmhLq96mttcBc38s1VSTbxQ3qUL+/K6dyghL4=
|
sha256-H18zIrryRN+tfQA68vfbWHNMN1mOxhO4PAWcZ4yuNSc=
|
||||||
|
|||||||
@@ -493,6 +493,53 @@ const x = 1;
|
|||||||
expect(status.aheadOfOrigin).toBeNull();
|
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 () => {
|
it("does not report incoming additions when the base branch is behind its remote", async () => {
|
||||||
const { cloneDir } = setupRemoteTrackingMain(repoDir, tempDir);
|
const { cloneDir } = setupRemoteTrackingMain(repoDir, tempDir);
|
||||||
commitFile(cloneDir, "file.txt", "remote one\nremote two\n", "remote update");
|
commitFile(cloneDir, "file.txt", "remote one\nremote two\n", "remote update");
|
||||||
|
|||||||
@@ -1268,6 +1268,7 @@ async function getAheadBehind(
|
|||||||
async function getAheadOfOrigin(
|
async function getAheadOfOrigin(
|
||||||
cwd: string,
|
cwd: string,
|
||||||
currentBranch: string,
|
currentBranch: string,
|
||||||
|
baseRef: string | null,
|
||||||
context?: CheckoutContext,
|
context?: CheckoutContext,
|
||||||
): Promise<number | null> {
|
): Promise<number | null> {
|
||||||
if (!currentBranch) {
|
if (!currentBranch) {
|
||||||
@@ -1286,12 +1287,15 @@ async function getAheadOfOrigin(
|
|||||||
if (trackedOriginBranch) {
|
if (trackedOriginBranch) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
if (!baseRef || normalizeLocalBranchRefName(baseRef) === currentBranch) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
const { stdout } = await runGitCommand(["rev-list", "--count", currentBranch], {
|
const comparisonBaseRef = await resolveBestComparisonBaseRef(cwd, baseRef, context);
|
||||||
cwd,
|
const { stdout } = await runGitCommand(
|
||||||
envOverlay: READ_ONLY_GIT_ENV,
|
["rev-list", "--count", `${comparisonBaseRef}..${currentBranch}`],
|
||||||
logger: context?.logger,
|
{ cwd, envOverlay: READ_ONLY_GIT_ENV, logger: context?.logger },
|
||||||
});
|
);
|
||||||
const count = Number.parseInt(stdout.trim(), 10);
|
const count = Number.parseInt(stdout.trim(), 10);
|
||||||
return Number.isNaN(count) ? null : count;
|
return Number.isNaN(count) ? null : count;
|
||||||
} catch {
|
} catch {
|
||||||
@@ -1503,7 +1507,7 @@ export async function getCheckoutStatus(
|
|||||||
? getAheadBehind(cwd, baseRef, currentBranch, context)
|
? getAheadBehind(cwd, baseRef, currentBranch, context)
|
||||||
: Promise.resolve(null),
|
: Promise.resolve(null),
|
||||||
hasRemote && currentBranch
|
hasRemote && currentBranch
|
||||||
? getAheadOfOrigin(cwd, currentBranch, context)
|
? getAheadOfOrigin(cwd, currentBranch, baseRef, context)
|
||||||
: Promise.resolve(null),
|
: Promise.resolve(null),
|
||||||
hasRemote && currentBranch
|
hasRemote && currentBranch
|
||||||
? getBehindOfOrigin(cwd, currentBranch, context)
|
? getBehindOfOrigin(cwd, currentBranch, context)
|
||||||
|
|||||||
Reference in New Issue
Block a user