Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: include all branch tips for shallow clone in deploy command #5828

Merged
merged 1 commit into from
Oct 29, 2021

Conversation

sivapalan
Copy link
Contributor

Fixes #5827

Motivation

Shallow clone of repository (introduced in #5748) fetches the default branch only.

From Git - git-clone Documentation:

--depth <depth>
Create a shallow clone with a history truncated to the specified number of commits. Implies --single-branch unless --no-single-branch is given to fetch the histories near the tips of all branches.

This causes git checkout of the deployment branch to fail (with version 2.0.0-beta.8 of @docusaurus/core):

Cloning into '/tmp/my-docs-gh-pagesQ1g5AP'...
CMD: git clone --depth 1 ***github.com/my-org/my-docs.git /tmp/my-docs-gh-pagesQ1g5AP (code: 0)
main
error: pathspec 'origin/gh-pages' did not match any file(s) known to git
CMD: git checkout origin/gh-pages (code: 1)
CMD: git checkout --orphan gh-pages (code: 0)

As a result of this, the command will go on to attempt to force push the orphan branch, and thereby overwrite any existing commits on the deployment branch (unless there is a branch protection rule preventing force pushes, in which case the deployment will fail altogether).

Adding --no-single-branch to the command should solve this issue.

An alternative solution with --branch ${deploymentBranch} could probably also be used here.

Have you read the Contributing Guidelines on pull requests?

Yes

Test Plan

Tested command locally.

Related PRs

#5748

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Oct 29, 2021
@netlify
Copy link

netlify bot commented Oct 29, 2021

✔️ [V2]
Built without sensitive environment variables

🔨 Explore the source changes: 61af1c4

🔍 Inspect the deploy log: https://app.netlify.com/sites/docusaurus-2/deploys/617c141dfd21db00079e8e4e

😎 Browse the preview: https://deploy-preview-5828--docusaurus-2.netlify.app

@github-actions
Copy link

⚡️ Lighthouse report for the changes in this PR:

Category Score
🟢 Performance 95
🟢 Accessibility 98
🟢 Best practices 100
🟢 SEO 100
🟢 PWA 95

Lighthouse ran on https://deploy-preview-5828--docusaurus-2.netlify.app/

@slorber slorber added the pr: bug fix This PR fixes a bug in a past release. label Oct 29, 2021
@slorber
Copy link
Collaborator

slorber commented Oct 29, 2021

Thanks, makes sense to me.

Should be a bit slower though, but probably not a big deal.

@nlfurniss let me know if you don't like this solution

@slorber slorber merged commit 8c12983 into facebook:main Oct 29, 2021
@nlfurniss
Copy link
Contributor

Thanks, makes sense to me.

Should be a bit slower though, but probably not a big deal.

@nlfurniss let me know if you don't like this solution

Seems good to me, sorry for causing an issue

@sivapalan sivapalan deleted the fix_deploy_command_shallow_clone branch October 29, 2021 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: bug fix This PR fixes a bug in a past release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deploy command is not able to checkout deployment branch
4 participants