From 69cc07b29c893fe29c9c553442bae81255715bd4 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Mon, 8 Jan 2024 16:16:59 +0100 Subject: [PATCH] Error with helpful message when publishing to Github pages `gh-pages` needs to be existing when publishing with `--no-prompt`. This could happen when initialiazing a new repo on CI without calling `quarto publish gh-pages` first locally, or creating the `gh-pages` branch manually. --- news/changelog-1.4.md | 1 + src/publish/gh-pages/gh-pages.ts | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/news/changelog-1.4.md b/news/changelog-1.4.md index c88b9ae51ce..f3efe7a6664 100644 --- a/news/changelog-1.4.md +++ b/news/changelog-1.4.md @@ -207,6 +207,7 @@ - ([#5436](https://github.com/quarto-dev/quarto-cli/issues/5436)): Add support for publishing to Posit Cloud. - ([#5220](https://github.com/quarto-dev/quarto-cli/issues/5220)): Properly respect `output-dir` when publishin individual files in a default Quarto project +- ([#4498](https://github.com/quarto-dev/quarto-cli/issues/4498)): Better error when `quarto publish gh-pages` fails because `gh-pages` branch does not exist on `origin` remote. ## Video (and Audio) diff --git a/src/publish/gh-pages/gh-pages.ts b/src/publish/gh-pages/gh-pages.ts index 68e557d3ad8..2907ac58d4e 100644 --- a/src/publish/gh-pages/gh-pages.ts +++ b/src/publish/gh-pages/gh-pages.ts @@ -96,6 +96,10 @@ async function publishRecord( id: "gh-pages", url: ghContext.siteUrl || ghContext.originUrl, }; + } else { + throwUnableToPublish( + 'the remote origin does not have a branch named "gh-pages". Use first `quarto publish gh-pages` locally to initialize the remote repository for publishing.', + ); } }