r-hub / rhub

R-hub API client
https://r-hub.github.io/rhub/
Other
347 stars 49 forks source link

Invalid URL when repo is "git@github.com:<username>/<repo>.git" #589

Closed coolbutuseless closed 2 months ago

coolbutuseless commented 2 months ago

Testing rhub v1.9.9.9000 and there appear to be some issues parsing the repo url, with a "git@..." address considered URL>

> rhub::rhub_doctor()
✔ Found R package at /Users/mike/projects/yyjsonr.
✔ Found git repository at /Users/mike/projects/yyjsonr.
✖ Do you have a GitHub personal access token (PAT)?
Invalid URL(s): git@github.com:coolbutuseless/yyjsonr.git

However if I explicitly set: `rhub::rhub_doctor("https://github.com/coolbutuseless/yyjsonr") then it works without complaint.

gaborcsardi commented 2 months ago

Thanks, can you show the output of traceback()?

coolbutuseless commented 2 months ago
> packageVersion('rhub')
[1] ‘1.9.9.9000’
> rhub::rhub_doctor()
✔ Found R package at /Users/mike/projects/yyjsonr.
✔ Found git repository at /Users/mike/projects/yyjsonr.
✖ Do you have a GitHub personal access token (PAT)?
Invalid URL(s): git@github.com:coolbutuseless/yyjsonr.git
gitcreds_cache_envvar(url)
NULL
NULL
69376
1712748956
0                                                                     , 1                                                                     , 2                                                                     , 3                                                                     , 4                                                                     , 5                                                                     , 6                                                                     , TRUE                                                                  , TRUE                                                                  , TRUE                                                                  , TRUE                                                                  , TRUE                                                                  , TRUE                                                                  , TRUE                                                                  , NA                                                                    , rhub                                                                  , base                                                                  , base                                                                  , base                                                                  , NA                                                                    , rhub                                                                  ,                                                                       , :::                                                                   , ::                                                                    , ::                                                                    , ::                                                                    ,                                                                       , :::                                                                   , 69376                                                                 , 69376                                                                 , 69376                                                                 , 69376                                                                 , 69376                                                                 , 69376                                                                 , 69376                                                                 , rhub::rhub_doctor()                                                   , doctor_find_pat(gh_url)                                               , tryCatch(pat <- gitcreds::gitcreds_get(url = pat_url)$password,       ,     gitcreds_nogit_error = function(e) {                              , tryCatchList(expr, classes, parentenv, handlers)                      , tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), ,     names[nh], parentenv, handlers[[nh]])                             , value[[3L]](cond)                                                     , throw(e)                                                              
> traceback()
8: base::stop(cond)
7: throw(e)
6: value[[3L]](cond)
5: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
       names[nh], parentenv, handlers[[nh]])
4: tryCatchList(expr, classes, parentenv, handlers)
3: tryCatch(pat <- gitcreds::gitcreds_get(url = pat_url)$password, 
       gitcreds_nogit_error = function(e) {
           cli::cli_status_clear(pid, result = "failed")
           env <- gitcreds::gitcreds_cache_envvar(pat_url)
           throw(pkg_error(call. = FALSE, "Could not find a GitHub personal access token (PAT) for {.url {pat_url}}.", 
               i = "I also could not find a working git installation. If you\n             don't want to install git, but you have a PAT, you can set the\n             {.env {env}} environment variable to the PAT.", 
               i = "You can read more about PATs at\n             {.url https://usethis.r-lib.org/articles/git-credentials.html}."))
       }, gitcreds_no_credentials = function(e) {
           cli::cli_status_clear(pid, result = "failed")
           env <- gitcreds::gitcreds_cache_envvar(pat_url)
           throw(pkg_error(call. = FALSE, "Could not find a GitHub personal access token (PAT) for {.url {pat_url}}.", 
               i = "If you have a GitHub PAT, you can use {.run gitcreds::gitcreds_set()}\n             to add it to the git credential store, so R-hub can use it.", 
               i = "If you don't have a PAT, you can create one by running\n             {.run usethis::create_github_token()}.", 
               i = "You can read more about PATs at\n             {.url https://usethis.r-lib.org/articles/git-credentials.html}."))
       }, error = function(e) {
           cli::cli_status_clear(pid, result = "failed")
           throw(e)
       })
2: doctor_find_pat(gh_url)
1: rhub::rhub_doctor()
gaborcsardi commented 2 months ago

I think it should be OK now.