Open MyKo101 opened 3 years ago
Hi, which version of gitcreds is this? I think the most recent version prints the output from git at least. Also, what was your git version before the upgrade?
Unfortunately since I've updated my git version, I don't know which version of git I was actually using. Do you know if there is any way to find out which version I was using? Would it be in any of the .git/
files of an old repo?
I'm on gitcred version 0.1.0.
I think that the throw(new_error(...))
line is supposed to be doing as you say, output the git output when an error is hit. But since it's hitting an unexpected git error (because of my ancient version), it's not being caught in the right way.
gitcreds 0.1.1 prints the output of git, I believe.
This is what I get for git 1.7.7:
Error in new_git_error("git_error", args = args, stdout = out, status = attr(out, :
System git failed: git: 'credential' is not a git command. See 'git --help'.
Is this better?
Checking the git version programmatically seems hard, because the git version strings are quite creative. E.g. my 1.7.7 prints this:
> system("git --version")
git version 1.7.7.GIT
So I am afraid that we would do more harm with trying to parse these strings.
Looking at the documentation for git
, I believe that the credential
command was introduced in version 2.25. Anything older than this wouldn't work with gitcreds
, right?
I think the git versions also all have the three standard parts (major.minor.patch) followed by other system-type versions (mine is now 2.30.0.windows.1
Something like this should work as a check:
git_version <- function(){
gv_raw <- system("git --version",intern=T)
v_location <- regexpr("([0-9]*?\\.[0-9]*?\\.[0-9]*\\.)",gv_raw)
gv_str <- regmatches(gv_raw,v_location)
as.numeric_version(substr(gv_str,1,nchar(gv_str)-1))
}
git_version()
if(git_version() < "2.25")
stop("git credentials only available in ")
I don't know a way to test this function with other versions of git
though so the results might be unpredictable so I understand your apprehension.
No, it is much older than that:
❯ git --version
git version 2.9.2
❯ git credential
usage: git credential [fill|approve|reject]
I've just had a quick look at the archive and it looks like credentials
was available at least as far back as 1.8.0, if your example of 1.7.7 is correct then it must have been introduced between those.
This is what I get for git 1.7.7:
Error in new_git_error("git_error", args = args, stdout = out, status = attr(out, : System git failed: git: 'credential' is not a git command. See 'git --help'.
Is this better?
Is this error just forwarding on the error from git
? Would it be possible to put in a little bit that says "Try updating git" or something to that effect?
I am not sure if it is possible to determine if the problem is an old git version. git credential
can fail various ways.
I was trying to follow along with the Github credentials guide on
usethis
and when I got to the point of runninggitcreds::gitcreds_set()
I got the following error:In this functions, there's a
tryCatch()
intending to grabgitcreds_no_credentials
and returnNULL
, however the error being thrown here is not agitcreds_no_credentials
condition and so the error was seeping through. The code goes on to rungitcreds_set_new(url)
if the condition is caught and I was getting the same error response.It took me way too long to realise my
git
version was out of date and after updating the error went away.It would be useful for
gitcreds
to check a user'sgit
version at some point in the process because the error I was receiving was very uninformative.