-
Notifications
You must be signed in to change notification settings - Fork 10
Add OpenSSH_jll as a direct dependency, and force our Git to use OpenSSH_jll (instead of the system ssh)
#55
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
Conversation
f9cf480 to
f842751
Compare
|
cc: @mortenpi |
|
Some of the Cirrus CI jobs are passing in the package test stage, but then failing in the Codecov submission. That should go away once we merge #56. |
|
The FreeBSD Cirrus CI failure will (hopefully) be fixed by #57. |
|
Locally I already had diff --git a/Project.toml b/Project.toml
index 3ebb083..512cffa 100644
--- a/Project.toml
+++ b/Project.toml
@@ -1,19 +1,21 @@
name = "Git"
uuid = "d7ba0133-e1db-5d97-8f8c-041e4b3a1eb2"
+version = "1.3.2"
authors = ["Dilum Aluthge", "contributors"]
-version = "1.3.1"
[deps]
Git_jll = "f8c6e375-362e-5223-8a59-34ff63f689eb"
+JLLWrappers = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210"
+OpenSSH_jll = "9bd350c2-7e96-507f-8002-3f2e150b4e1b"
[compat]
Git_jll = "2.44"
JLLWrappers = "1.1"
+OpenSSH_jll = "9, 10"
julia = "1.6"
[extras]
-JLLWrappers = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
[targets]
-test = ["JLLWrappers", "Test"]
+test = ["Test"]
diff --git a/src/git_function.jl b/src/git_function.jl
index 867f697..a218928 100644
--- a/src/git_function.jl
+++ b/src/git_function.jl
@@ -1,3 +1,6 @@
+using OpenSSH_jll: OpenSSH_jll
+using JLLWrappers: pathsep, LIBPATH_env
+
"""
git()
@@ -18,8 +21,8 @@ julia> run(git(["clone", "https://github.com/JuliaRegistries/General"]))
to bypass the parsing of the command string.
"""
function git(; adjust_PATH::Bool = true, adjust_LIBPATH::Bool = true)
- @static if Sys.iswindows()
- return Git_jll.git(; adjust_PATH, adjust_LIBPATH)::Cmd
+ git_cmd = @static if Sys.iswindows()
+ Git_jll.git(; adjust_PATH, adjust_LIBPATH)::Cmd
else
root = Git_jll.artifact_dir
@@ -45,8 +48,24 @@ function git(; adjust_PATH::Bool = true, adjust_LIBPATH::Bool = true)
end
original_cmd = Git_jll.git(; adjust_PATH, adjust_LIBPATH)::Cmd
- return addenv(original_cmd, env_mapping...)::Cmd
+ addenv(original_cmd, env_mapping...)::Cmd
end
+
+ # Use OpenSSH from the JLL: <https://github.com/JuliaVersionControl/Git.jl/issues/51>.
+ if OpenSSH_jll.is_available()
+ path = split(get(ENV, "PATH", ""), pathsep)
+ libpath = split(get(ENV, LIBPATH_env, ""), pathsep)
+
+ path = vcat(dirname(OpenSSH_jll.ssh_path), path)
+ libpath = vcat(OpenSSH_jll.LIBPATH_list, libpath)
+
+ unique!(filter!(!isempty, path))
+ unique!(filter!(!isempty, libpath))
+
+ git_cmd = addenv(git_cmd, "PATH" => join(path, pathsep), LIBPATH_env => join(libpath, pathsep))
+ end
+
+ return git_cmd
end
function git(args::AbstractVector{<:AbstractString}; kwargs...)which looks cleaner to me, but I was trying to figure out how to test this (always needs a key pair, which we can't ensure) |
|
I would probably bump the minor version number, because this feels a bit like a new feature to me, but other than that LGTM. For testing, can we just generate a new SSH keypair on the fly, and then discard it at the end of our tests? Or does it need to be an SSH keypair that is known to GitHub? |
I presume the latter. |
|
We could add a test that we only do on CI (skip locally). We can generate a new SSH keypair, and add it to this repo as a deploy key with read-only permissions, and add the private key as a GitHub Actions secret. And then have a CI-only test that uses this SSH deploy key to clone this repo? |
|
BTW, your diff applies this "prepend OpenSSH_jll" behavior to both Windows and non-Windows. Is this necessary? I was assuming we could just bypass this whole thing on Windows, and just apply this patch for the non-Windows codepath. |
I don't see why Windows should be any different (besides the fact it's slightly less likely users may have
That could work. |
|
@giordano You can force-push your version to my branch, and take over this PR (or you can open a new PR if you've already pushed your branch). |
|
The test I had in mind was @testset "OpenSSH integration" begin
if # something....
withtempdir() do dir
@test !isdir("Git.jl")
@test !isfile(joinpath("Git.jl", "Project.toml"))
@test success(`$(git()) clone --depth=1 [email protected]:JuliaVersionControl/Git.jl.git`)
@test isdir("Git.jl")
@test isfile(joinpath("Git.jl", "Project.toml"))
end
end
endWould you be able to finish up the testing part? |
My thinking is:
|
|
I just checked on a Windows machine that I have. When I open Git Bash, the first SSH client in the PATH is the SSH that ships built-in to Git Bash. |
Yep. I will create the deploy key and push the tests shortly. |
|
I have:
|
|
Ubuntu CI is failing with: |
|
I don't see |
|
Ah, I see, so maybe we aren't including it when we re-bundle the upstream Git for Windows? |
I do see it in |
|
Of note, Windows is passing on Julia 1.11, but failing on Julia 1.6. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #55 +/- ##
==========================================
+ Coverage 95.45% 96.96% +1.51%
==========================================
Files 1 1
Lines 22 33 +11
==========================================
+ Hits 21 32 +11
Misses 1 1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
I have no idea how the |
|
Alright, so I did some testing on a Windows machine, and here is what I found. First, I opened Task Manager, and I made sure that there were no Then, I opened Julia, and did Then I did: using Git: git
run(`$(git()) clone [email protected]:JuliaRegistries/General.git`)I don't have any Screenshot 1 of 3:
Screenshot 2 of 3:
Screenshot 3 of 3 (I'm hovering over the "path" so that the full path is shown):
So, from this testing, it looks to me that when I use Git.jl (latest registered version) on Windows, by default it will use the I assume Git-for-Windows does some magic to make sure that their own SSH gets picked up, instead of a system SSH. |
* Don't do the `OpenSSH_jll` stuff on Windows * Run CI on all PRs (regardless of the target branch)
|
Could we get this into a release? |
|
It's in |
|
Sorry I only looked at https://github.com/JuliaVersionControl/Git.jl/releases and it is not listed there. So I assume TagBot integration here is broken? Indeed, your commit fc28591 likely broke it. Indeed, the |
Yeah, well, I copied from there, if that's wrong it's broken for everyone. |
|
it is indeed broken for "everyone". I'll report to TagBot |
|
ah actually I did report it in March (phew! I felt bad because I thought "why the heck did I not report this when I run into it). Unfortunately I got no reactions by anyone "in charge". I have no idea who that would be ... :-( |



Fixes #51, fixes julia-actions/julia-docdeploy#40.