Skip to content

gh_pages publish error #406

@t3573393

Description

@t3573393

Environment

OS: ubuntu 17.10
Node: v6.11.4
npm: 5.6.0
yarn: 1.3.2
(OS, Node, npm, yarn)

Steps to Reproduce

  1. publish use local project to remote use : yarn run publish-gh-pages command, first time is ok, but when checkout the second time fail;

  2. error info shows:

    $ docusaurus-publish
    master
    generate.js triggered...
    feed.js triggered...
    feed.js triggered...
    Site built successfully. Generated files in 'build' folder.
    Cloning into 'fartpig.github.io-master'...
    git clone ok
    Note: checking out 'origin/master'.

    You are in 'detached HEAD' state. You can look around, make experimental
    changes and commit them, and you can discard any commits you make in this
    state without impacting any branches by performing another checkout.

    If you want to create a new branch to retain commits you create, you may
    do so (now or later) by using -b with the checkout command again. Example:

    git checkout -b

    HEAD is now at 254a030... Delete CNAME
    fatal: A branch named 'master' already exists.
    fatal: could not set upstream of HEAD to origin/master when it does not point to any branch.
    Error: Git checkout master failed
    error Command failed with exit code 1.
    info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

  3. when i git log the branch , they has the same SHA code between the detached commit and master branch.

When I note the code :

if (shell.exec(`git checkout origin/${DEPLOYMENT_BRANCH}`).code !== 0) {
  if (shell.exec(`git checkout --orphan ${DEPLOYMENT_BRANCH}`).code !== 0) {
    shell.echo(`Error: Git checkout ${DEPLOYMENT_BRANCH} failed`);
    shell.exit(1);
  }
} else {
  if (
    shell.exec(`git checkout -b ${DEPLOYMENT_BRANCH}`).code +
      shell.exec(`git branch --set-upstream-to=origin/${DEPLOYMENT_BRANCH}`)
        .code !==
    0
  ) {
    shell.echo(`Error: Git checkout ${DEPLOYMENT_BRANCH} failed`);
    shell.exit(1);
  }
}

in docusaurus-publish.js , then it works. I thinks this should have a branch check before operation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    difficulty: starterIssues that are starter difficulty level, e.g. minimal tweaking with a clear test plan.documentationThe issue is related to the documentation of Docusaurusgood first issueIf you are just getting started with Docusaurus, this issue should be a good place to begin.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions