diff --git a/src/actions_utils.ts b/src/actions_utils.ts index 734cb072..cb7647ec 100644 --- a/src/actions_utils.ts +++ b/src/actions_utils.ts @@ -147,7 +147,7 @@ export class ActionOutputPrinter { if (this.config.searchFor) searchOutputForHints(this.config, stdoutBuffer); if (stdoutBuffer.length === 0) { console.log( - chalk`{yellow No groups found for action {cyan ${this.actionToRun}} and group {cyan ${this.groupToRun}}}`, + chalk`{yellow No groups found for action {cyan ${this.actionToRun}} and group in {cyan ${this.groupToRun}}}`, ); } fs.writeFileSync(path.join(this.config.cwd, ".output.json"), JSON.stringify(stdoutBuffer)); diff --git a/src/gitops.ts b/src/gitops.ts index 6f445602..3cd10b74 100644 --- a/src/gitops.ts +++ b/src/gitops.ts @@ -26,9 +26,11 @@ async function pull(dir: string, currentBranch: string, log: LogFn) { if (err || !res) { if (`${err?.stderr}`.trim().startsWith("There is no tracking information for the current branch")) { - log(chalk`{cyan ${currentBranch}} {red doesn't have a remote origin} {cyan ${dir}}`); + log(chalk`{cyan ${currentBranch}} {red doesn't have a remote origin} in {cyan ${dir}}`); + } else if (`${err?.stderr}`.trim().startsWith(`Your configuration specifies to merge with the ref`)) { + log(chalk`{cyan ${currentBranch}} {red no such ref could be fetched} in {cyan ${dir}}`); } else { - log(chalk`{cyan ${currentBranch}} {red conflicts} with {magenta origin/${currentBranch}} {cyan ${dir}}`); + log(chalk`{cyan ${currentBranch}} {red conflicts} with {magenta origin/${currentBranch}} in {cyan ${dir}}`); } return false; } diff --git a/tests/gitops.test.ts b/tests/gitops.test.ts index b006d850..5337517e 100644 --- a/tests/gitops.test.ts +++ b/tests/gitops.test.ts @@ -89,7 +89,7 @@ describe("Git Operations", () => { const logs = await gitops(cwdStub, projectStub); - expect(logs).toContain(chalk`{cyan main} {red doesn't have a remote origin} {cyan ${cwdStub}/cego/example}`); + expect(logs).toContain(chalk`{cyan main} {red doesn't have a remote origin} in {cyan ${cwdStub}/cego/example}`); }); test("Already up to date", async () => { @@ -111,6 +111,18 @@ describe("Git Operations", () => { expect(spawnSpy).toHaveBeenCalledWith("git", ["pull", "--ff-only"], expect.objectContaining({})); }); + test("Remote ref has gone away", async () => { + mockHasNoChanges(); + when(spawnSpy) + .calledWith("git", ["pull", "--ff-only"], expect.objectContaining({})) + .mockRejectedValue({ stderr: "Your configuration specifies to merge with the ref" }); + + const logs = await gitops(cwdStub, projectStub); + const msg = chalk`{cyan main} {red no such ref could be fetched} in {cyan ${cwdStub}/cego/example}`; + expect(logs).toContain(msg); + expect(spawnSpy).toHaveBeenCalledWith("git", ["pull", "--ff-only"], expect.objectContaining({})); + }); + test("Conflicts with origin", async () => { mockHasNoChanges(); when(spawnSpy) @@ -118,7 +130,7 @@ describe("Git Operations", () => { .mockRejectedValue({ stderr: "I'M IN CONFLICT" }); const logs = await gitops(cwdStub, projectStub); - const msg = chalk`{cyan main} {red conflicts} with {magenta origin/main} {cyan ${cwdStub}/cego/example}`; + const msg = chalk`{cyan main} {red conflicts} with {magenta origin/main} in {cyan ${cwdStub}/cego/example}`; expect(logs).toContain(msg); }); });