Allow for remote names other than origin.#2509
Conversation
We introduce `getremotename` that tries to check the `remote.pushDefault` option to determine the remote name, and falls back to `origin` if it's not set.
|
Generally, I think trying to use
|
|
Thanks for the thoughts. I have changed the workflow to default to |
| """ | ||
| $(TYPEDSIGNATURES) | ||
|
|
||
| Determines the GitHub remote of a directory, returninf 'origin' if that remote exists, |
There was a problem hiding this comment.
| Determines the GitHub remote of a directory, returninf 'origin' if that remote exists, | |
| Determines the GitHub remote of a directory, returning `origin` if that remote exists, |
| @assert !isempty(pushdefault) | ||
| @warn "Remote 'origin' not found. Using `git config --get remote.pushDefault` instead, which is set to '$(pushdefault)'." | ||
| return pushdefault | ||
| catch ; end |
There was a problem hiding this comment.
I suspect this PR needs to be reformatted with runic
| try | ||
| originurl = readchomp(setenv(`$(git()) config --get remote.origin.url`; dir=dir)) | ||
| @assert !isempty(originurl) | ||
| return "origin" | ||
| catch; end |
There was a problem hiding this comment.
You seem to be using @assert plus try/catch for control flow. That seems like a bad idea for multiple reasons (e.g. future Julia version might allow disabling @assert checks, which is, I think, mainly intended to enforce to check runtime invariants, which is not what this code does).
How about just e.g. this
| try | |
| originurl = readchomp(setenv(`$(git()) config --get remote.origin.url`; dir=dir)) | |
| @assert !isempty(originurl) | |
| return "origin" | |
| catch; end | |
| originurl = readchomp(setenv(`$(git()) config --get remote.origin.url`; dir=dir)) | |
| if !isempty(originurl) | |
| return "origin" | |
| end |
There was a problem hiding this comment.
Same applies to the rest of the code, of course
| to construct the warning messages. | ||
| """ | ||
| function git_remote_head_branch(varname, root; remotename = "origin", fallback = "master") | ||
| function git_remote_head_branch(varname, root; fallback = "master") |
There was a problem hiding this comment.
The docstring still references remotename. So either that needs to be adjusted. Alternatively, keep the kwarg here, but with a new default value nothing; and then later only call getremotename if remotename === nothing ?
|
@RomeoV are you still interested in this? If so, some conflicts need to be resolved now and a bunch of comments should be addressed. If not, let's close it? |
|
I have no bandwidth right now for this unfortunately, and also no use at this time. So we can close the PR. I appreciate your review and thoughtful comments, though. If you would like this merged i can address the comments some time later in November. |
We introduce
getremotenamethat tries to check theremote.pushDefaultoption to determine the remote name, and falls back tooriginif it's not set.Fixes #2464 and perhaps #1916, as well as https://discourse.julialang.org/t/creating-documentation-when-remote-name-is-not-origin/110466.