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

Sparse checkout not working with recent git versions #37

Closed
rmunoz opened this issue Jul 15, 2022 · 7 comments
Closed

Sparse checkout not working with recent git versions #37

rmunoz opened this issue Jul 15, 2022 · 7 comments

Comments

@rmunoz
Copy link

rmunoz commented Jul 15, 2022

GitHub Actions recently updated their virtual environments (see ubuntu-latest for example) and now git cli version is 2.37. This is causing problems with git sparse-checkout set used in sparse_clone.sh script because it doesn't admit patterns to be passed.

Looking at the git docs for a version that works and the one that doesn't seems that we we need to pass --no-cone flag in order to keep using patterns in the sparse checkout. I tested locally modifying the script in my local virtual environment and works but I'm not sure if it's the "real" fix, not very familiar with sparse checkouts.

@jorgheymans
Copy link

jorgheymans commented Jul 15, 2022

I spent some time debugging the same issue and just came to report my findings.

In sparse_clone.sh, when I remove the --sparse option alltogether everything starts working. Indeed, with the --sparse option it only checks out the repository root. The script relies on the subsequent call to git sparse-checkout which fails, when you add an exit code check like the clone itself this becomes clear:

+git sparse-checkout set ${dirs[*]} || exit 1

You see that it fails:

fatal: 'mkdocs.yml' is not a directory; to treat it as a directory anyway, rerun with --skip-checks

When having a look at the contents of ${dirs[*]} , I see that in my case it expands to mkdocs mkdocs.yml. Note that i configured my docs_dir to mkdocs so that is expected. That it is passing also mkdocs.yml is probably not expected. My attempts at digging further were hampered by my lack of python knowledge, so i hope above info is useful to troubleshoot things.

@jdoiro3
Copy link
Owner

jdoiro3 commented Jul 15, 2022

@rmunoz, thanks for raising this issue. I see your company forked the repo and you made some changes. Feel free to create a pull request. You could even add the runners that have the newer git version to the integration tests to make sure this works with the newer version.

@rmunoz
Copy link
Author

rmunoz commented Jul 15, 2022

@jdoiro3 yep, tbh is just a quick and dirty workaround to unblock my team that basically adds the --no-cone to the sparse_clone python function:

args = [self.url, self.name, self.branch] + ["--no-cone"] + dirs

I'm going to be off for two weeks (summer break) but once I'll be back my plan is to prepare a proper fix checking the git version as you're already doing for older git versions.

@jdoiro3
Copy link
Owner

jdoiro3 commented Jul 24, 2022

@rmunoz and @jorgheymans - as an FYI I have a PR (#40) where I'm starting to run integration tests with different versions of git and python.

@jdoiro3
Copy link
Owner

jdoiro3 commented Jul 24, 2022

This should be fixed with v0.4.4. Please let me know if this in fact is still an issue.

@jdoiro3 jdoiro3 closed this as completed Jul 24, 2022
@jorgheymans
Copy link

Thanks @jdoiro3 it works now !

@rmunoz
Copy link
Author

rmunoz commented Aug 1, 2022

Thanks @jdoiro3, it works fine 👏

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

No branches or pull requests

3 participants