quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.74k stars 305 forks source link

Invalid error when attempting to publish #8221

Closed dragonstyle closed 7 months ago

dragonstyle commented 7 months ago

I'm attempting to test publish to confluence, but if I do:

quarto create project confluence c
cd c
quarto publish

I receive an error about a missing gh-pages branch before even selecting the publishing target

ERROR: Unable to publish to GitHub Pages (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.)

Stack trace:
    at throwUnableToPublish (file:///Users/ct/Development/quarto-dev/quarto-cli/src/publish/gh-pages/gh-pages.ts:428:9)
    at Object.publishRecord (file:///Users/ct/Development/quarto-dev/quarto-cli/src/publish/gh-pages/gh-pages.ts:100:5)
    at eventLoopTick (ext:core/01_core.js:183:11)
    at async publishDeployments (file:///Users/ct/Development/quarto-dev/quarto-cli/src/command/publish/deployment.ts:118:22)
    at async resolveDeployment (file:///Users/ct/Development/quarto-dev/quarto-cli/src/command/publish/deployment.ts:35:23)
    at async publishAction (file:///Users/ct/Development/quarto-dev/quarto-cli/src/command/publish/cmd.ts:211:7)
    at async Command.fn (file:///Users/ct/Development/quarto-dev/quarto-cli/src/command/publish/cmd.ts:152:11)
    at async Command.execute (file:///Users/ct/Development/quarto-dev/quarto-cli/src/vendor/deno.land/x/cliffy@v0.25.4/command/command.ts:1790:7)
    at async quarto (file:///Users/ct/Development/quarto-dev/quarto-cli/src/quarto.ts:155:3)
    at async file:///Users/ct/Development/quarto-dev/quarto-cli/src/quarto.ts:186:5
mcanouil commented 7 months ago

This new message seems to come from:

mcanouil commented 7 months ago

I think the issue is that quarto publish methods are not really independent as they initially shared an obscure error message for instance about the missing config file for Quarto Pub even when publishing to GitHub Pages. There is probably some refactoring to plan on the publish sub-routines.

dragonstyle commented 7 months ago

I think this check might just need to be deferred to a later time once the user has elected to publish to gh-pages. I reviewed that PR so my bad of not catching it!

mcanouil commented 7 months ago

What i still don't understand is why quarto publish which is able to create gh-pages needs to be run locally first while in GitHub Actions, setting contents: write should allow to write branches but here Quarto will fail. The first version of quarto publish did not create gh-pages so the error made sense at that time, but now it basically causes headaches to several users without obvious reasons at least to me.

cderv commented 7 months ago

Oups. I really thought by adding this in the a function tied to github page publishing this would be ok... my bad. I'll fix this !

What i still don't understand is why quarto publish which is able to create gh-pages needs to be run locally first while in GitHub Actions, setting contents: write should allow to write branches but here Quarto will fail.

We only do the branch creation when prompt is opt-in so not when --no-prompt. This is a design choice to only allow quarto publish to create the gh-branch on a user's confirmation at command line.

The first version of quarto publish did not create gh-pages so the error made sense at that time, but now it basically causes headaches to several users without obvious reasons at least to me.

When it did not create the branch, it would still fail on publishing right ? It seem we just need to clarify the code path used for each publishing provider so that we error accordingly

cderv commented 7 months ago

The error was added in the publishRecord() function from the github pages provider https://github.com/quarto-dev/quarto-cli/blob/27983066d0bfb5e5057c1deed6808f20c23c42a1/src/publish/gh-pages/gh-pages.ts#L38-L51

but it seems we call this even before choosing the deployment. I'll try to adapt

cderv commented 7 months ago

Ok so we do check all the providers records when no is providing. I missed that. https://github.com/quarto-dev/quarto-cli/blob/27983066d0bfb5e5057c1deed6808f20c23c42a1/src/command/publish/deployment.ts#L112-L126

cderv commented 7 months ago

PR is up . Fix is to indeed defer to a later time and only throw when gh-pages is chosen as publishing provider.