Skip to content

Commit

Permalink
Fixed edge case where n_versions = 0 (#838)
Browse files Browse the repository at this point in the history
* Fixed edge case where n_versions = 0

* Update NEWS

---------

Co-authored-by: Julia Silge <julia.silge@gmail.com>
  • Loading branch information
MichalLauer and juliasilge authored Aug 27, 2024
1 parent 2edcccb commit 58082a3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

* Fixed a bug in handling folders with duplicate names for Google Drive (#819, @UchidaMizuki)

* Fixed how previously deleted pin versions are detected (#838, @MichalLauer)

# pins 1.3.0

## Breaking changes
Expand Down
24 changes: 14 additions & 10 deletions R/pin_versions.R
Original file line number Diff line number Diff line change
Expand Up @@ -157,19 +157,23 @@ version_from_path <- function(x) {
}

version_setup <- function(board, name, new_version, versioned = NULL, call = caller_env()) {

n_versions <- 0

if (pin_exists(board, name)) {
versions <- pin_versions(board, name)
old_version <- versions$version[[1]]
n_versions <- nrow(versions)
if (old_version == new_version) {
cli::cli_abort(c(
"The new version {.val {new_version}} is the same as the most recent version.",
i = "Did you try to create a new version with the same timestamp as the last version?"
),
call = call)

if (n_versions > 0) {
old_version <- versions$version[[1]]
if (old_version == new_version) {
cli::cli_abort(c(
"The new version {.val {new_version}} is the same as the most recent version.",
i = "Did you try to create a new version with the same timestamp as the last version?"
),
call = call)
}
}
} else {
n_versions <- 0
}

versioned <- versioned %||% if (n_versions > 1) TRUE else board$versioned
Expand All @@ -184,4 +188,4 @@ version_setup <- function(board, name, new_version, versioned = NULL, call = cal
}

new_version
}
}

0 comments on commit 58082a3

Please sign in to comment.