Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed edge case where n_versions = 0 #838

Merged
merged 2 commits into from
Aug 27, 2024

Conversation

MichalLauer
Copy link
Contributor

Fixes #837.

Here is a reprex of the fix:

library(pins)

# Prepare data
write.csv(mtcars, file = "mtcars.csv")

# Create temp board and first upload
board <- board_temp(versioned = TRUE)
pin_upload(board = board, paths = "mtcars.csv", name = "data")
#> Creating new version '20240827T112516Z-cd94d'

# Returns one version
pin_versions(board, "data")
#> # A tibble: 1 × 3
#>   version                created             hash 
#>   <chr>                  <dttm>              <chr>
#> 1 20240827T112516Z-cd94d 2024-08-27 13:25:16 cd94d

# Delete just created pin
latest_version <- pin_versions(board = board, name = "data")$version
pin_version_delete(board = board, name = "data", version = latest_version)

# Returns an empty tibble
pin_versions(board, "data")
#> # A tibble: 0 × 3
#> # ℹ 3 variables: version <chr>, created <dttm>, hash <chr>

# Upload new data
pin_upload(board = board, paths = "mtcars.csv", name = "data")
#> Creating new version '20240827T112516Z-cd94d'

# Returns one version
pin_versions(board, "data")
#> # A tibble: 1 × 3
#>   version                created             hash 
#>   <chr>                  <dttm>              <chr>
#> 1 20240827T112516Z-cd94d 2024-08-27 13:25:16 cd94d

Created on 2024-08-27 with reprex v2.1.1

I also simplified the if statement in version_setup as the solution introduced another layer of if-else statements.
If anything is missing, feel free to let me know :)

Copy link
Member

@juliasilge juliasilge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much @MichalLauer! 🙌

@juliasilge juliasilge merged commit 58082a3 into rstudio:main Aug 27, 2024
14 checks passed
@MichalLauer
Copy link
Contributor Author

Thank you too @juliasilge! 🥇

Copy link

This pull request has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error when deleting last version of a pin
2 participants