Skip to content
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

Trying to make gert:::git_submodule_update with custom gitlab instance #174

Open
pokyah opened this issue May 12, 2022 · 0 comments
Open

Comments

@pokyah
Copy link

pokyah commented May 12, 2022

Hi,

context
For my company, I need to automate some git workflows where we need to manage git submodules. This has to be done from within a wider R project and using HTTP only (SSH is not implemented and the IT department is not ready to make it work due to reverse proxy complications...).

objective
Create a git repo, add a submodule with the content of its nested submodules (see reprex here below)

problem
My problem is that I encounter en error while using gert::git_submodule_update if interacting with my company's gitlab instance :

Error in libgit2::git_submodule_update : 
  request failed with status code: 401
  • This error does not arrise if executing git submodule update --init from git bash

  • I don't encounter any error while using other gert functions that require auth like gert::git_clone or gert::git_pull for example. The error is only relative to gert::git_submodule_update

  • If trying to do the same operation with a github hosted dummy example, everything works fine with HTTP (see reprex here below).

Please also note that calling a system or sys::exec_wait or system2 function and passing it the args to build git submodule update --init command is not considered as a solution as the R script might be called by some user from within KNIME (an opensource ETL tool) with which, I had no success to make a system call to execute a git submodule update --init command working (which might be a clue for some credentials problems?).

reprex
The script here below should :

  • create an empty git repo,
  • add the repo https://github.com/pokyah/test_gert_submodule_l1 that contains a submodule test_gert_submodule_l2 as a subrepo
  • and pull the content of the nested submodule test_gert_submodule_l2

If everything works fine there should be a goodbye.R file into the nested test_gert_submodule_l2 folder

subfix = floor(as.numeric(Sys.time()))
test_dir = paste0("test_gert", subfix)

desktop = paste0("C:/users/", Sys.getenv("USERNAME"), "/Desktop/")
test_dir = paste0(desktop, test_dir)
dir.create(test_dir)

github_url = "https://github.com/pokyah/test_gert_submodule_l1"
gitlab_be_url = "https://git.environnement.brussels/evaluation-ace/ben-factory/tools/suites/csv-suite"
ref_github = "main"
ref_belb = "master"

gert::git_init(path = test_dir)

gert::git_submodule_add(
  url = github_url,
  path = paste0("components/", basename(github_url)),
  ref = ref_github,
  repo = test_dir)

submodule = gert::git_submodule_list(
  repo = paste0(test_dir))

gert::git_submodule_init(
  submodule = submodule$path,
  repo = test_dir,
  overwrite = T)

submodule_submodule = gert::git_submodule_list(
  repo = paste0(test_dir, "/", submodule$path))

gert::git_submodule_init(
  submodule = submodule_submodule$path,
  repo = paste0(test_dir, "/", submodule$path),
  overwrite = T)

gert:::git_submodule_update(
  submodule = submodule_submodule$path,
  repo = paste0(test_dir, "/", submodule$path))

question

Do you have any idea of what could explain why gert:::git_submodule_update does not work with a specific gitlab instance?
In https://github.com/r-lib/gert/blob/main/R/submodules.R you mention in the function comment :

# I find this confusing, also doesn't support auth.
# Better use git_submodule_fetch()

What does it really mean ?
If we could get more information about this problem, this could help us automate our git workflows within our R project and maybe help us understand my git submodule update --init command called from a system call within KNIME does not work neither.

session info

R version 4.1.3 (2022-03-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)

Matrix products: default

locale:
[1] LC_COLLATE=French_Belgium.1252  LC_CTYPE=French_Belgium.1252   
[3] LC_MONETARY=French_Belgium.1252 LC_NUMERIC=C                   
[5] LC_TIME=French_Belgium.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] benFactoR_0.1.5

loaded via a namespace (and not attached):
 [1] gert_1.6.0        here_1.0.1        tidyr_1.2.0       arpr_0.1.2       
 [5] prettyunits_1.1.1 ps_1.6.0          assertthat_0.2.1  rprojroot_2.0.3  
 [9] digest_0.6.29     utf8_1.2.2        R6_2.5.1          sys_3.4          
[13] evaluate_0.15     httr_1.4.2        pillar_1.7.0      rlang_1.0.2      
[17] curl_4.3.2        rstudioapi_0.13   callr_3.7.0       rmarkdown_2.13   
[21] desc_1.4.1        devtools_2.4.3    webshot_0.5.2     stringr_1.4.0    
[25] compiler_4.1.3    xfun_0.30         pkgconfig_2.0.3   askpass_1.1      
[29] base64enc_0.1-3   pkgbuild_1.3.1    Rserve_1.8-10     htmltools_0.5.2  
[33] openssl_2.0.0     tidyselect_1.1.2  tibble_3.1.6      roxygen2_7.1.2   
[37] gitlabr_2.0.0     fansi_1.0.3       crayon_1.5.1      dplyr_1.0.8      
[41] withr_2.5.0       brio_1.1.3        jsonlite_1.8.0    lifecycle_1.0.1  
[45] DBI_1.1.2         git2r_0.30.1      magrittr_2.0.3    credentials_1.3.2
[49] cli_3.2.0         stringi_1.7.6     cachem_1.0.6      renv_0.15.4      
[53] fs_1.5.2          remotes_2.4.2     testthat_3.1.3    xml2_1.3.3       
[57] ellipsis_0.3.2    generics_0.1.2    vctrs_0.4.0       tools_4.1.3      
[61] glue_1.6.2        purrr_0.3.4       processx_3.5.3    pkgload_1.2.4    
[65] fastmap_1.1.0     yaml_2.3.5        sessioninfo_1.2.2 memoise_2.0.1    
[69] knitr_1.38        usethis_2.1.5    

Many thanks for your support.

Best regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant