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 git checkout fallback, make ls-remote filtering stricter #364

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

antongolub
Copy link

@antongolub antongolub commented Jul 1, 2020

PR is an attempt to fix #349

@antongolub
Copy link
Author

@tschaub, could you take a look?

@antongolub
Copy link
Author

@tschaub
We use gh-pages as part of semantic-release plugin. Therefore, we also face the mentioned problem. Should we fix it on our side or right here? What do you think?

@tschaub
Copy link
Owner

tschaub commented Jul 29, 2020

@antongolub - I'll admit it isn't clear to me what situation fails before this change and succeeds after. Having a test that demonstrates what this fixes would be ideal. I understand that might be hard to put together though. Could you try to put together a test? Or if not, could you provide steps for someone else to reproduce the problem that this fixes?

@antongolub
Copy link
Author

@tschaub

The current check makes no diff between tag and branch. if we just add origin/gh-pages label to some commit, then it will be found by git ls-remote . origin/gh-pages

Example repo: https://github.com/antongolub/yarn-audit-fix

git ls-remote .

efe39653c6756ac01aca74eec31c65d2b8ac5a4e        HEAD
1b179d780a6ee927c9cae29d366478ebdc5b0292        refs/heads/master
efe39653c6756ac01aca74eec31c65d2b8ac5a4e        refs/remotes/origin/HEAD
efe39653c6756ac01aca74eec31c65d2b8ac5a4e        refs/remotes/origin/master
15e62b754342e27e496bfaf4ceae92763e97ad65        refs/remotes/origin/renovate/typescript-3.x
196e133a568770b34ce25dee1b179b348f7da3e3        refs/tags/gh-pages
efe39653c6756ac01aca74eec31c65d2b8ac5a4e        refs/tags/gh-pages^{}
094c04c89a3dcbce04777b1345884341e5d60c39        refs/tags/origin/gh-pages
efe39653c6756ac01aca74eec31c65d2b8ac5a4e        refs/tags/origin/gh-pages^{}
825d70be9eb62f00f7a720df3913269fa5fb49d2        refs/tags/v1.0.0
4259b0bf69cf14665868e0f9860e792d01715c83        refs/tags/v1.1.0
1d4ad333ec5cb07b2086c76fde123060b402b376        refs/tags/v1.1.1

git ls-remote . origin/gh-pages

git ls-remote . origin/gh-pages
094c04c89a3dcbce04777b1345884341e5d60c39        refs/tags/origin/gh-pages

@tschaub
Copy link
Owner

tschaub commented Jul 31, 2020

I was looking for something more like the steps required to reproduce the problem you are trying to solve.

@antongolub
Copy link
Author

antongolub commented Jul 31, 2020

Scenario

  1. Create a blank repo.
  2. git clone new.repo.git
  3. Create a remote branch that ends with origin/gh-pages.
    git checkout --orphan foo/bar/origin/gh-pages && git rm -rf . && git commit --allow-empty -m "empty" && git push origin foo/bar/origin/gh-pages
  4. git checkout master
  5. Generate docs. mkdir docs && echo 'docs' > docs/doc.txt
  6. NODE_DEBUG=gh-pages npx gh-pages -d docs
GH-PAGES 37941: Cloning git@github.com:antongolub/yarn-audit-fix.git into /Users/a.golub/projects/yarn-audit-fix/node_modules/.cache/gh-pages/git@github.com!antongolub!yarn-audit-fix.git
GH-PAGES 37941: Cleaning
GH-PAGES 37941: Fetching origin
GH-PAGES 37941: Checking out origin/gh-pages 
error: pathspec 'gh-pages' did not match any file(s) known to git

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Command Breaks After Deleting the gh-pages Branch
2 participants