-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Make utility for generating git url string #23040
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -195,6 +195,94 @@ end | |
end | ||
end | ||
|
||
@testset "Git URL formatting" begin | ||
@testset "HTTPS URL" begin | ||
url = LibGit2.git_url( | ||
scheme="https", | ||
username="user", | ||
password="pass", | ||
host="server.com", | ||
port=80, | ||
path="/org/project.git") | ||
@test url == "https://user:[email protected]:80/org/project.git" | ||
end | ||
|
||
@testset "SSH URL" begin | ||
url = LibGit2.git_url( | ||
scheme="ssh", | ||
username="user", | ||
password="pass", | ||
host="server", | ||
port="22", | ||
path="/project.git") | ||
@test url == "ssh://user:pass@server:22/project.git" | ||
end | ||
|
||
@testset "SSH URL, scp-like syntax" begin | ||
url = LibGit2.git_url( | ||
scheme="", | ||
username="user", | ||
host="server", | ||
path="project.git") | ||
@test url == "user@server:project.git" | ||
end | ||
|
||
@testset "HTTPS URL, realistic" begin | ||
url = LibGit2.git_url( | ||
scheme="https", | ||
host="github.com", | ||
path="/JuliaLang/Example.jl.git") | ||
@test url == "https://github.com/JuliaLang/Example.jl.git" | ||
end | ||
|
||
@testset "SSH URL, realistic" begin | ||
url = LibGit2.git_url( | ||
username="git", | ||
host="github.com", | ||
path="JuliaLang/Example.jl.git") | ||
@test url == "[email protected]:JuliaLang/Example.jl.git" | ||
end | ||
|
||
@testset "HTTPS URL, no path" begin | ||
url = LibGit2.git_url( | ||
scheme="https", | ||
username="user", | ||
password="pass", | ||
host="server.com", | ||
port="80") | ||
@test url == "https://user:[email protected]:80" | ||
end | ||
|
||
@testset "scp-like syntax, no path" begin | ||
url = LibGit2.git_url( | ||
username="user", | ||
host="server.com") | ||
@test url == "[email protected]" | ||
end | ||
|
||
@testset "HTTP URL, path missing slash prefix" begin | ||
url = LibGit2.git_url( | ||
scheme="http", | ||
host="server.com", | ||
path="path") | ||
@test url == "http://server.com/path" | ||
end | ||
|
||
@testset "empty" begin | ||
@test_throws ArgumentError LibGit2.git_url() | ||
|
||
@test LibGit2.git_url(host="server.com") == "server.com" | ||
url = LibGit2.git_url( | ||
scheme="", | ||
username="", | ||
password="", | ||
host="server.com", | ||
port="", | ||
path="") | ||
@test url == "server.com" | ||
end | ||
end | ||
|
||
mktempdir() do dir | ||
# test parameters | ||
repo_url = "https://github.com/JuliaLang/Example.jl" | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Slight change to behaviour here. It used to be that when the
schema
was not defined in the URL the credential ID would be"$host"
now it will be"ssh://$host"
.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'm not sure defaulting to ssh is any better than requiring setting a schema
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.
Note that using the scp-like syntax
[email protected]:JuliaLang/julia.git
orssh://[email protected]/JuliaLang/julia.git
both refer to the same git repo using the SSH protocol.The advantage of defaulting to using SSH here is that both of these syntaxes will refer to the same
credid
.See https://git-scm.com/book/id/v2/Git-on-the-Server-The-Protocols (under "The SSH Protocol" section)
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.
We could just assign "ssh" to be the schema when one is missing but this would then modify the
git_url
output from[email protected]:repo.git
tossh://[email protected]/repo.git
which would no longer resemble the URL passed in by the user.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.
what would happen on
[email protected]/JuliaLang/julia.git
?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.
Based upon the behavour of
git clone
that URL should be invalid.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.
right but if it gets passed here will you be prepending
ssh
to 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.
Currently yes. I'll update the URL_REGEX to fix this.
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.
URL_REGEX no longer allows
[email protected]/JuliaLang/julia.git