-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
…ion_tag()` and works when the version tag is on a diverged branch (e.g., after squash-merging) (#844) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: krlmlr <[email protected]>
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#' The most recent versioned tag | ||
#' | ||
#' Returns the Git tag of the form vx.y, vx.y.z or vx.y.z.w with the latest version. | ||
#' An older version of this logic is used in [get_last_tag()], | ||
#' which traverses the Git history but does not work with squash-merging of version bumps. | ||
#' | ||
#' @inherit get_last_tag return | ||
#' | ||
#' @example man/examples/get-last-version-tag.R | ||
#' | ||
#' @export | ||
get_last_version_tag <- function() { | ||
with_repo(get_last_version_tag_impl()) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# 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.") | ||
# Switch to branch for bumping version. | ||
gert::git_branch_create("fledge") | ||
# Bump version with fledge. | ||
fledge::bump_version(check_default_branch = FALSE) | ||
fledge::finalize_version() | ||
|
||
# Merge the version bump branch into main. | ||
gert::git_branch_checkout("main") | ||
gert::git_merge("fledge", squash = TRUE) | ||
|
||
print(get_top_level_commits(since = NULL)) | ||
|
||
# get_last_tag() doesn't work in this scenario | ||
print(fledge::get_last_tag()) | ||
|
||
# get_last_version_tag() is better | ||
print(fledge::get_last_version_tag()) | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.