Suggestion: allow all remote branches to be fetched via config?
Opened this issue · 3 comments
First off, thank you for creating this project. It's helped me out tremendously!
Describe the bug
I have a use case where I want to use multi-gitter to operate on different remote branches. Within my script, I want to check-out multiple remote branches and perform some steps so I can compare the differences later. However to my initial confusion, the only remote branch I'm able to access is the default branch
To Reproduce
Steps to reproduce the behavior:
Expected behavior
I expected to see all remote branches (similar to what I'd see running git branch -a
locally). It wasn't until I did some searching that I found the CloneOptions
here. My understanding is that this only clones a single branch?
Is it possible to make the SingleBranch
bool configurable? (if that's the root cause, happy to be corrected if it isn't!)
Additional context
If you're happy to accept contributions, I can raise something similar to this PR to make the property configurable!
I fully understand that my specific use case is on the more bizarre end and probably not what multi-gitter was intended for, hence why I'm asking about this first. TIA!
Could you describe your exact use-case a bit more? And are you using run
or print
?
I do think this could potentially be added. But in that case, we also need to ensure that the user will get appropriate error messages if, for example, they do multi-gitter run
and leave the checked-out branch to not be the expected one.
Absolutely, at a high level we're looking to verify an organisation-wide upgrade of one of our key dependencies. Since this is a breaking change and a substantial number of our repos don't have adequate snapshot testing, we decided that the best approach is to create a PR to show the diff pre and post-upgrade.
To do this, we run the following operations in our script:
- Checkout the default branch (
main
/master
) - Produce a snapshot, push this to a
before-upgrade
branch - Checkout our upgrade branch (branch with a static name)
- Produce a snapshot, push this to an
after-upgrade
branch - Create a PR, with the changes of
after-upgrade
based off thebefore-upgrade
branch - Add a comment to a static PR, linking to the newly-created PR
The reason that we're creating the PR ourselves and not using multi-gitter is that we need the PR to compare the diff between before-upgrade
and after-upgrade
, but to get this diff we need the base branch to initially be main
/master
. Also adding the reference comment requires us to know the PR link in advance.
And we're using run
to execute our script against repos. We're using --dry-run
, as the script is creating all the GitHub artifacts
I've been able to work around this by running the following in my script before checking out the upgrade branch:
git config remote.origin.fetch +refs/heads/*:refs/remotes/origin/*
git fetch --unshallow
If this functionality is required by others I'm happy to add this, but I'll leave this up to your judgement as to whether to close this issue or not!