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

Add support for '#' in git branch names (as git does not disallow them) #4813

Closed
wants to merge 3 commits into from
Closed

Conversation

s0undt3ch
Copy link

Considering the following URL 'git+ssh://[email protected]/owner/reponame.git@issue#2035#egg=Reponame', previously we'd get an error similar to:

Collecting Reponame from git+ssh://[email protected]/owner/reponame.git@issue#2035#egg=Reponame
  Cloning ssh://[email protected]/owner/reponame.git (to issue) to /tmp/vampas/pip-build-ftjipp8c/Reponame
  Could not find a tag or branch 'issue', assuming commit.
error: pathspec 'issue' did not match any file(s) known to git.

With this change, we check for an existing '#' in the frag part of the
parsed URL and add back the remaining of the path in such case.

We now get something like:

Collecting Reponame from git+ssh://[email protected]/owner/reponame.git@issue#2035#egg=Reponame
  Cloning ssh://[email protected]/owner/reponame.git (to revision issue#2035) to /tmp/vampas/pip-install-jjs7njl1/Reponame
Installing collected packages: Reponame
  Running setup.py install for Reponame ... done
Successfully installed Reponame-5.2

@pradyunsg pradyunsg added state: needs discussion This needs some more discussion type: enhancement Improvements to functionality C: vcs pip's interaction with version control systems like git, svn and bzr labels Oct 26, 2017
@@ -227,6 +227,10 @@ def get_url_rev(self):
assert '+' in self.url, error_message % self.url
url = self.url.split('+', 1)[1]
scheme, netloc, path, query, frag = urllib_parse.urlsplit(url)
if '#' in frag:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like this code may be more elegant if you pass allow_fragments=False to the call to urlsplit(), in part because you're effectively parsing the fragment yourself anyways.

@s0undt3ch
Copy link
Author

Good point. I'll update the PR.

@cjerdonek
Copy link
Member

I agree with @pradyunsg that discussion is needed here. Would another possible approach be to require that the "url" portion of the location be quoted, and then the "revision" portion (e.g. branch name) be unquoted when parsing it? This way, a "#" symbol could be represented using "%23". This also wouldn't require any changes to the parsing logic (aside from possibly unquoting the revision).

The above is just an idea for discussion purposes and might not work as I stated it (e.g. for backwards compatibility reasons if we already accept many unquoted characters, or for other reasons).

@pradyunsg pradyunsg changed the title Because git does not disallow '#' in branch names, handle them Add support for '#' in git branch names (as git does not disallow them) Oct 28, 2017
Considering the following URL 'git+ssh://[email protected]/owner/reponame.git@issue#2035#egg=Reponame', previously we'd get an error similar to:
```
Collecting Reponame from git+ssh://[email protected]/owner/reponame.git@issue#2035#egg=Reponame
  Cloning ssh://[email protected]/owner/reponame.git (to issue) to /tmp/vampas/pip-build-ftjipp8c/Reponame
  Could not find a tag or branch 'issue', assuming commit.
error: pathspec 'issue' did not match any file(s) known to git.
```

With this change, we check for an existing '#' in the frag part of the
parsed URL and add back the remaining of the path in such case.

We now get something like:
```
Collecting Reponame from git+ssh://[email protected]/owner/reponame.git@issue#2035#egg=Reponame
  Cloning ssh://[email protected]/owner/reponame.git (to revision issue#2035) to /tmp/vampas/pip-install-jjs7njl1/Reponame
Installing collected packages: Reponame
  Running setup.py install for Reponame ... done
Successfully installed Reponame-5.2
```
@s0undt3ch
Copy link
Author

PR Updated

@BrownTruck
Copy link
Contributor

Hello!

I am an automated bot and I have noticed that this pull request is not currently able to be merged. If you are able to either merge the master branch into this pull request or rebase this pull request against master then it will eligible for code review and hopefully merging!

@BrownTruck BrownTruck added the needs rebase or merge PR has conflicts with current master label Jul 16, 2018
@s0undt3ch s0undt3ch closed this Aug 25, 2018
@cjerdonek
Copy link
Member

I think this should be kept open (or least kept open as an issue if not a PR).

@cjerdonek cjerdonek reopened this Aug 25, 2018
@s0undt3ch
Copy link
Author

We're now building packages so this will no longer be an issue for us.
I also don't have time to work on it.
If someone wants to pick up where I left, cool.

@pradyunsg
Copy link
Member

@cjerdonek If OP doesn't really have the need for this anymore and since no one else has requested this, I'm happy to let this PR get closed.

If someone else does want this functionality at some point in the future, I think they'll come around to this or given how simple this change is, submit an equivalent PR -- both of which are fine IMO.

@cjerdonek
Copy link
Member

cjerdonek commented Aug 26, 2018 via email

@pradyunsg
Copy link
Member

Sure. Please do.

@cjerdonek
Copy link
Member

I opened issue #5742 for this.

@cjerdonek cjerdonek closed this Aug 27, 2018
@pradyunsg
Copy link
Member

Thanks. :)

@lock
Copy link

lock bot commented Jun 1, 2019

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

@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Jun 1, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jun 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation C: vcs pip's interaction with version control systems like git, svn and bzr needs rebase or merge PR has conflicts with current master state: needs discussion This needs some more discussion type: enhancement Improvements to functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants