-
Notifications
You must be signed in to change notification settings - Fork 701
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
Don't use --detach
when cloning, fixes #6888
#6927
Conversation
--detached
when cloning, fixes #6888--detached
when cloning, fixes #6888
This is now ready for review. |
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.
I'd expect to see some additions to https://github.com/haskell/cabal/blob/master/cabal-install/tests/UnitTests/Distribution/Client/VCS.hs testing VCS support.
To run tests:
# use cabal-install.cabal with tests
make cabal-install-dev
# build and run test-suite
cabal run cabal-install:unit-tests
--detached
when cloning, fixes #6888--detach
when cloning, fixes #6888
I'd love to help, but I'm not really sure where to start on adding tests. The errors that this PR fix occur when you run When you first # Clone the repository.
git clone repo
# Construct a new local branch named "B" that tracks the branch named "B" from the remote "origin".
git branch B --track origin/B
# Switch to the local branch named "B".
git checkout B Running This is why an error occurs when passing I'm not sure how to construct this scenario in the tests. I think the right answer might be to modify |
Would it suffice to add a test which verifies that checking out a branch name (rather than a commit hash) works as expected? Seems to me we can be very confident that this patch won't break anything... cabal won't ever make any commits to the repositories it clones, so it doesn't matter whether they are in detached HEAD state, right? |
While this does make the error go away, it's not the correct fix I am afraid, as it never updates the branch from the remote. The A better fix is to keep the |
I was revising conflicts and |
Please include the following checklist in your PR:
changelog.d
directory).Please also shortly describe how you tested your change. Bonus points for added tests!
I think this fixes #6888 but I'm not sure how to write an automated test for this.
#6888 happens because we use
--detach
even when we are checking out branch names. This causesgit
to fail with the error messagefatal: '--detach' cannot be used with '-b/-B/--orphan'
. To the best of my knowledge, there's no reason to ever prefer--detached
over regular tag names, so I've removed that flag.I tested this fix by using the binary built from this commit to successfully build and run my project that depends on a non-
master
branch of a Git repository for an external package. Here is the exact commit that does not compile on with cabal-install 3.2.0.0, but does compile with this patch.