-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
docs: Document how to fetch additional branches #10795
docs: Document how to fetch additional branches #10795
Conversation
Tools like reno depend on a complete git history. Simply unshallowing a clone is not sufficient, as we specifically fetch from the branch or tag that we are building docs for, e.g.: git fetch origin --force --prune --prune-tags --depth 50 refs/heads/main:refs/remotes/origin/main Add documentation describing how you can correct this if necessary. Signed-off-by: Stephen Finucane <stephen@that.guru>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution. If there's a specific tool that this is useful for, it's probably worth mentioning in the text, so it's easier to Google for.
jobs: | ||
post_checkout: | ||
- git fetch --unshallow || true | ||
- git config remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*' || true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this line required? Seems pretty specific to a use case, and something I'd expect git to do by default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is necessary because we're configuring git to only fetch a single branch in this command (which you'll see a variant of in all builds):
git fetch origin --force --prune --prune-tags --depth 50 refs/heads/main:refs/remotes/origin/main
If you shallow clone a repo then run the above locally and look at .git/config
, you'll see something like the following:
[remote "origin"]
fetch = +refs/heads/main:refs/remotes/origin/main
Which means "map the main
ref locally to the main
remote ref". Because we've limited fetch to a single branch, we will always get just that single branch no matter what flags we pass. To fix this, you need to tell git to fetch all branches and map them to the same name locally, which is what we're doing here.
Perhaps there's another way to override the config file during a fetch operation, but if there is I'm not aware of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, and as I mentioned in the blurb beforehand, you'll need to do this if you have a tool that needs access to other branches rather than just other tags.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha -- Thanks!
Tools like reno depend on a complete git history. Simply unshallowing a clone is not sufficient, as we specifically fetch from the branch or tag that we are building docs for, e.g.:
Add documentation describing how you can correct this if necessary.
📚 Documentation previews 📚
docs
): https://docs--10795.org.readthedocs.build/en/10795/dev
): https://dev--10795.org.readthedocs.build/en/10795/