Skip to content

don't interpret HEAD as a faulty branch #6874

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

Closed

Conversation

dimbleby
Copy link
Contributor

with this requirement

caput = { git = "https://github.com/radiocosmology/caput.git", extras = ["compression"] }

and using dulwich as the git client, we get:

Failed to clone https://github.com/radiocosmology/caput.git at 'HEAD', verify ref exists on remote.

What seems to happen is we go through the branch

elif (
self.revision.encode("utf-8") in remote_refs.refs
or f"refs/heads/{self.revision}".encode() in remote_refs.refs
):
# this is most likely a ref spec or a branch incorrectly specified
self.branch = self.revision
self.revision = None
, correcting "HEAD" to be treated as a branch with that name - and that later goes wrong.

I don't really understand what's going on in this code, maybe someone who does can contribute a testcase

Another fix that I tried was

--- a/src/poetry/puzzle/provider.py
+++ b/src/poetry/puzzle/provider.py
@@ -111,7 +111,7 @@ def _get_package_from_git(
     package = Provider.get_package_from_directory(path)
     package._source_type = "git"
     package._source_url = url
-    package._source_reference = rev or tag or branch or "HEAD"
+    package._source_reference = rev or tag or branch
     package._source_resolved_reference = revision
     package._source_subdirectory = subdirectory

which solved this case, but did quite a bit more damage to the unit tests.

@neersighted neersighted mentioned this pull request Oct 23, 2022
4 tasks
abn added a commit to abn/poetry that referenced this pull request Nov 14, 2022
This change ensures that when ref `HEAD` is specified, it is not incorrectly
resolved to `refs/head/HEAD`. `HEAD` is not treated as a branch, and correctly
resolved from the ref spec.

Resolves: python-poetry#7024
Closes: python-poetry#6874
@abn
Copy link
Member

abn commented Nov 14, 2022

@dimbleby I have raised #7028 with a slightly different fix since it seems HEAD should really be treated as a branch from what I can tell. Added some test cases too. Your changes helped track down the issue fast! 🎉

@dimbleby dimbleby closed this Nov 16, 2022
@dimbleby dimbleby deleted the head-is-not-a-bad-branch branch November 16, 2022 13:35
abn added a commit to abn/poetry that referenced this pull request Feb 23, 2024
This change ensures that when ref `HEAD` is specified, it is not incorrectly
resolved to `refs/head/HEAD`. `HEAD` is not treated as a branch, and correctly
resolved from the ref spec.

Resolves: python-poetry#7024
Closes: python-poetry#6874
abn added a commit to abn/poetry that referenced this pull request Feb 23, 2024
This change ensures that when ref `HEAD` is specified, it is not incorrectly
resolved to `refs/head/HEAD`. `HEAD` is not treated as a branch, and correctly
resolved from the ref spec.

Resolves: python-poetry#7024
Closes: python-poetry#6874
abn added a commit to abn/poetry that referenced this pull request Feb 25, 2024
This change ensures that when ref `HEAD` is specified, it is not incorrectly
resolved to `refs/head/HEAD`. `HEAD` is not treated as a branch, and correctly
resolved from the ref spec.

Resolves: python-poetry#7024
Closes: python-poetry#6874
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 29, 2024
abn added a commit to abn/poetry that referenced this pull request Mar 2, 2024
This change ensures that when ref `HEAD` is specified, it is not incorrectly
resolved to `refs/head/HEAD`. `HEAD` is not treated as a branch, and correctly
resolved from the ref spec.

Resolves: python-poetry#7024
Closes: python-poetry#6874
abn added a commit that referenced this pull request Mar 2, 2024
This change ensures that when ref `HEAD` is specified, it is not incorrectly
resolved to `refs/head/HEAD`. `HEAD` is not treated as a branch, and correctly
resolved from the ref spec.

Resolves: #7024
Closes: #6874
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants