-
-
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
Refactor LibGit2.set_remote_url
#22062
Conversation
if push != url | ||
set!(cfg, "remote.$remote.pushurl", push) | ||
end | ||
end |
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.
Caused #21773
Feature or bugfix? |
looks like a little of both, plus a new deprecation |
base/libgit2/remote.jl
Outdated
repo_path = joinpath("test_directory", "Example") | ||
repo = LibGit2.init(repo_path) | ||
url1 = "https://github.com/JuliaLang/Example.jl" | ||
LibGit2.set_remote_url(repo, url1, remote="upstream") |
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.
bit misleading to name the argument at the call site if it's positional
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 missed this when I moved away from a keyword.
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.
Fixed
base/deprecated.jl
Outdated
if remote_kwarg === nothing | ||
return remote_arg | ||
else | ||
msg = "$f($sig; remote=\"$remote_kwarg\") is deprecated, use $f($sig, \"$remote_kwarg\")" |
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.
these usually end with "instead"
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.
Ok. I modeled this off of the deprecate_negate
function. Does the rest of this seem reasonable?
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 wrote that one, and went through a couple refactors of it. it does say instead in it.
the argument order differs from the libgit2 c functions', but I guess that's okay. positionals always run the risk of "what order is it supposed to be" when writing or reading code that uses the method, so I'm neutral on this part of the change
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 modeled this off of the deprecate_negate function. Does the rest of this seem reasonable?
I should have been more specific. I was wondering if the deprecate_remote_keyword
function was reasonable.
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.
the argument order differs from the libgit2 c functions'
Re-ordering the functions to be func(repo::GitRepo, remote::AbstractString, url::AbstractString)
would more closely match both LibGit2 and the git command line. Personally I am fine with always having to specify the remote name.
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.
Done
test/libgit2.jl
Outdated
@@ -37,6 +37,15 @@ function with_libgit2_temp_home(f) | |||
end | |||
end | |||
|
|||
function is_defined_remote(repo::LibGit2.GitRepo, remote::AbstractString) | |||
try | |||
LibGit2.get(LibGit2.GitRemote, repo, name) |
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.
can this be done without try-catching?
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'll look into this again tomorrow. I didn't find a LibGit2 method which seemed to cover 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.
Made lookup_remote
to address this
test/libgit2.jl
Outdated
@test !is_defined_remote(repo, name) | ||
|
||
# Set just the fetch URL | ||
LibGit2.set_remote_fetch_url(repo, url, name) |
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.
this is testing the repo::GitRepo
versions pretty well, and the existing block was testing some of the path::AbstractString
versions, but not the ones you're newly adding
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'll extend the tests to cover those.
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.
Done
Definitely both. When addressing the bug I noticed that the GitConfig was being used to modify the remote rather than using the available LibGit2 functions. Using the config method is bad as it doesn't verify that things like the remote name is valid. After getting my hands into the code I noticed that the remote keyword was unnecessary which is how I ended up here. |
I'll add some docstrings to the new functions in addition to the review change requests. |
I guess what I was getting at was is this backportable to 0.6 or does it need to stay on master? |
I can separate the bugfix so it can be backported to 0.6. |
29fb185
to
729f891
Compare
Anything left to do here? Maybe a NEWS entry? |
base/libgit2/remote.jl
Outdated
function set_remote_push_url end | ||
|
||
function set_remote_push_url(repo::GitRepo, remote_name::AbstractString, url::AbstractString) | ||
@check ccall((:git_remote_set_pushurl, :libgit2), Cint, |
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.
under-indented
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.
Nice catch
Changes include: - Creating `set_remote_fetch_url`, `set_remote_push_url`, `remote_delete`, and `lookup_remote` - Updating `set_remote_url` to use LibGit2 calls - Deprecate `set_remote_url` which uses keyword and reorder arguments to match order of `GitRemote` constructor. - Update all existing calls to `set_remote_url`
Rebased to resolve conflict in "base/deprecated.jl" |
Ready for merge |
didn't add a news entry, were you going to? |
I wasn't planning on adding one but I will now. |
[ci skip]
NEWS entry added. |
Added new functions
set_remote_fetch_url
andset_remote_push_url
which allow you to specify the fetch/push remote URLs independently. Additionally, I switchedset_remote_url
from using a the keyword remote to using an optional argument.Fixes #21773