Returns the most recent Git tag.

get_last_tag()

Value

A one-row tibble with columns name, ref and commit. For annotated tags (as created by fledge), commit may be different from the SHA of the commit that this tag points to. Use gert::git_log() to find the actual commit.

Examples

# Create mock package in a temporary directory.
# Set open to TRUE if you want to play in the mock package.
with_demo_project({
  # Use functions as if inside the newly created package project.
  # (Or go and actually run code inside the newly created package project!)
  # Add a new R file.
  usethis::use_r("cool-function", open = FALSE)
  # Pretend we added useful code inside it.
  # Track the new R file with Git.
  gert::git_add("R/cool-function.R")
  gert::git_commit("- Add cool function.")
  # Bump version with fledge.
  fledge::bump_version()
  fledge::finalize_version()
  print(get_top_level_commits(since = NULL))
  print(fledge::get_last_tag())
})
#>  Setting active project to '/tmp/Rtmp8nQpx7/fledge37f45f75f37f/tea'
#>  Edit 'R/cool-function.R'
#>  Call `use_test()` to create a matching test file
#> → Scraping 3 commit messages.
#>  Found 1 NEWS-worthy entries.
#> 
#> ── Updating NEWS ──
#> 
#> → Adding new entries to NEWS.md.
#> Warning: 'Date' must be an ISO date: yyyy-mm-dd, but it is actually better to leave       this field out completely. It is not required.
#> 
#> ── Update Version ──
#> 
#>  Package version bumped to 0.0.0.9001.
#> → Adding header to NEWS.md.
#> → Committing changes.
#> 
#> ── Tagging Version ──
#> 
#> → Creating tag v0.0.0.9001 with tag message derived from NEWS.md.
#>  Edit 'NEWS.md'
#> ! Call `fledge::finalize_version()`.
#> → Resetting to previous commit.
#> → Committing changes.
#> 
#> ── Tagging Version ──
#> 
#>  Tag v0.0.0.9001 exists and points to the current commit.
#> # A tibble: 4 × 2
#>   commit                                   message                          
#>   <chr>                                    <chr>                            
#> 1 24be06c4f6a44b5919bf1ce0d777ba25ce259820 "Bump version to 0.0.0.9001\n"   
#> 2 0a9c01f4df1809f8d9500b46b60e736b5d2be5ab "- Add cool function.\n"         
#> 3 7661c165916a0fbca65198ac17fbf9d00950b877 "Add NEWS.md to track changes.\n"
#> 4 7d5ab64fcbf97a2addb707736a74ae6a64085648 "First commit\n"                 
#> # A tibble: 1 × 3
#>   name        ref                   commit                                  
#> * <chr>       <chr>                 <chr>                                   
#> 1 v0.0.0.9001 refs/tags/v0.0.0.9001 0dd7efae6fdeb914d7188729505eb93e8bb24021
#>  Setting active project to '<no active project>'