r-lib / gert

Simple git client for R
https://docs.ropensci.org/gert/
Other
146 stars 31 forks source link

Detect non-existent git tag? #187

Closed eitsupi closed 1 year ago

eitsupi commented 1 year ago

Thank you for developing this wonderful package.

I have been using this package to monitor the release of new versions of RStudio and today I noticed an error detecting a tag that does not exist (v2022.07.2+576^{}). https://github.com/rocker-org/rocker-versioned2/actions/runs/3104603323/jobs/5030296512

I don't know if this is a bug of gert, but using git on the command line does not seem to detect this non-existent tag.

gert::git_remote_ls(remote = "https://github.com/rstudio/rstudio") |>
    dplyr::filter(stringr::str_detect(ref, "^refs/tags/v")) |>
    dplyr::arrange(dplyr::desc(ref))
#> # A tibble: 2,989 × 3
#>    ref                         symref oid                                     
#>    <chr>                       <chr>  <chr>                                   
#>  1 refs/tags/v2022.07.2+576^{} NA     e7373ef832b49b2a9b88162cfe7eac5f22c40b34
#>  2 refs/tags/v2022.07.2+576    NA     53277fece0515762daf614069fa5c11eaf1edee0
#>  3 refs/tags/v2022.07.1+554    NA     7872775ebddc40635780ca1ed238934c3345c5de
#>  4 refs/tags/v2022.07.0+548    NA     34ea3031089fa4e38738a9256d6fa6d70629c822
#>  5 refs/tags/v2022.02.4+500    NA     c0935c0fbfb2172b2f6c60cbae6c50dbc196b2eb
#>  6 refs/tags/v2022.02.3+492    NA     aaa7a713740a0767e6476f025b85cc57769e3283
#>  7 refs/tags/v2022.02.2+485    NA     8acbd38b0d4ca3c86c570cf4112a8180c48cc6fb
#>  8 refs/tags/v2022.02.1+461    NA     8aaa5d470dd82d615130dbf663ace5c7992d48e3
#>  9 refs/tags/v2022.02.0+443    NA     9f7969398b90468440a501cf065295d9050bb776
#> 10 refs/tags/v2021.09.4+403    NA     621070f02f3d2efc5e00b830f745c096c5f9d64d
#> # … with 2,979 more rows
#> # ℹ Use `print(n = ...)` to see more rows
$ git ls-remote --tags --refs --sort='version:refname' https://github.com/rstudio/rstudio.git v\* | tail -n 10 | tac
53277fece0515762daf614069fa5c11eaf1edee0        refs/tags/v2022.07.2+576
7872775ebddc40635780ca1ed238934c3345c5de        refs/tags/v2022.07.1+554
34ea3031089fa4e38738a9256d6fa6d70629c822        refs/tags/v2022.07.0+548
c0935c0fbfb2172b2f6c60cbae6c50dbc196b2eb        refs/tags/v2022.02.4+500
aaa7a713740a0767e6476f025b85cc57769e3283        refs/tags/v2022.02.3+492
8acbd38b0d4ca3c86c570cf4112a8180c48cc6fb        refs/tags/v2022.02.2+485
8aaa5d470dd82d615130dbf663ace5c7992d48e3        refs/tags/v2022.02.1+461
9f7969398b90468440a501cf065295d9050bb776        refs/tags/v2022.02.0+443
621070f02f3d2efc5e00b830f745c096c5f9d64d        refs/tags/v2021.09.4+403
d3cd0996032c29f309544fc22b6d955a23313c5d        refs/tags/v2021.09.3+396

I am wondering why git cli and gert work differently.

eitsupi commented 1 year ago

There is no commit 53277fece0515762daf614069fa5c11eaf1edee0 that can be seen in the git CLI and gert, and it appears that commit e7373ef832b49b2a9b88162cfe7eac5f22c40b34 only detected by gert is the commit that currently has tag v2022.07.2+576...... Perhaps a cache or other issue? https://github.com/rstudio/rstudio/commit/e7373ef832b49b2a9b88162cfe7eac5f22c40b34

jeroen commented 1 year ago

I learned about this recently: this means the tag is an annotated tag object. The value with ^{} is the peeled version of the annotated tag, i.e. the actual reference to a commit like a lightweight tag. See more details here.

FWIW, the results are consistent with command line git:

git ls-remote https://github.com/rstudio/rstudio | grep '2022.07.2+576'
53277fece0515762daf614069fa5c11eaf1edee0    refs/tags/v2022.07.2+576
e7373ef832b49b2a9b88162cfe7eac5f22c40b34    refs/tags/v2022.07.2+576^{}
eitsupi commented 1 year ago

Thank you for the explanation! Git is very deep......