From a1bfe2484ea3c57a8338a0679cafe688ccb6b780 Mon Sep 17 00:00:00 2001 From: Michal Lauer Date: Tue, 27 Aug 2024 13:18:35 +0200 Subject: [PATCH 1/2] Fixed edge case where n_versions = 0 --- R/pin_versions.R | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/R/pin_versions.R b/R/pin_versions.R index 3053cefe..4d2981cd 100644 --- a/R/pin_versions.R +++ b/R/pin_versions.R @@ -157,19 +157,22 @@ 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 @@ -184,4 +187,4 @@ version_setup <- function(board, name, new_version, versioned = NULL, call = cal } new_version -} +} \ No newline at end of file From 45acaf5572b29935c05582666a36a1df01762a29 Mon Sep 17 00:00:00 2001 From: Julia Silge Date: Tue, 27 Aug 2024 11:47:39 -0600 Subject: [PATCH 2/2] Update NEWS --- NEWS.md | 2 ++ R/pin_versions.R | 1 + 2 files changed, 3 insertions(+) diff --git a/NEWS.md b/NEWS.md index f62ca534..acd2943b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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 diff --git a/R/pin_versions.R b/R/pin_versions.R index 4d2981cd..7045a86d 100644 --- a/R/pin_versions.R +++ b/R/pin_versions.R @@ -159,6 +159,7 @@ 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) n_versions <- nrow(versions)