Skip to content

Fix versioning#15

Merged
randrescastaneda merged 4 commits intomasterfrom
fix_versioning
Mar 4, 2026
Merged

Fix versioning#15
randrescastaneda merged 4 commits intomasterfrom
fix_versioning

Conversation

@dana89co
Copy link
Collaborator

@dana89co dana89co commented Mar 4, 2026

Hola @randrescastaneda,
I had to fix a bug in stamp because the default versioning ("content") was not working and files with the same content hash were saved many times. I also created a small log you can review. Let me know if you have questions.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed content-based versioning to correctly skip saving when content remains unchanged.
    • Improved path handling in save operations to use relative paths appropriately.
    • Resolved path normalization issues that were causing double-nesting.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 4, 2026

📝 Walkthrough

Walkthrough

Package version bumped from 0.0.9 to 0.0.10 with bug fixes for IO versioning. Corrects st_save() to pass relative path instead of storage path to st_should_save(), preventing double normalization and incorrect save decisions. Removes two unused internal path-resolution functions. Adds regression test for identical-content handling.

Changes

Cohort / File(s) Summary
Version & Metadata
DESCRIPTION, NEWS.md
Version bump to 0.0.10 with changelog entry documenting bug fixes for versioning, path handling, and redundant code removal.
Core Logic Fixes
R/IO_core.R
Fixed st_save() to pass rel_path instead of storage_path to st_should_save(); simplified st_changed_reason() to delegate normalization directly to st_changed().
Dead Code Removal
R/aaa.R
Deleted .st_resolve_file_path() and .st_resolve_and_normalize() internal functions (157 lines), eliminating redundant path-resolution wrappers.
Documentation & Logging
copilot_logs/LOG_fix_versioning.md, man/dot-st_resolve_*.Rd
Added detailed fix documentation log; removed man page entries for deleted internal functions.
Regression Testing
tests/testthat/test-should-save.R
Added regression test verifying st_save() correctly skips saving identical content and maintains proper versioning behavior.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • Data.table_standarization #2: Modifies st_save() in R/IO_core.R with related changes to argument forwarding, sharing the same function-level scope as this PR's path-handling fix.

Suggested reviewers

  • randrescastaneda

Poem

🐰 Hop, skip, and save with glee,
Double paths? We set them free!
Tests now pass, the logic's right,
Versioning fixed—content's tight!
Dead code gone, the code's more spry,
Quality leap—reaching for the sky!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix versioning' directly describes the main objective of the PR, which is fixing a bug in the versioning system where files with identical content were being saved multiple times.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix_versioning

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
copilot_logs/LOG_fix_versioning.md (1)

51-51: Optional wording polish: use hyphenated “To-Do”.

Tiny readability/style tweak for the section header.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@copilot_logs/LOG_fix_versioning.md` at line 51, Update the section header
string "To Do List" to the hyphenated form "To-Do List" to match the requested
style; locate the header text "To Do List" in the document and replace it with
"To-Do List" so the section uses the hyphenated wording.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/testthat/test-should-save.R`:
- Around line 83-115: The test relies on global st_opts state so make it
deterministic by explicitly setting the versioning mode before saves; call
st_opts(versioning = "content", default_format = "qs2") (or at minimum set
versioning = "content") near the start of the test (before the first st_save) so
the behavior of st_save, st_versions and skipped/no_change_policy checks is
consistent; update the test that uses st_init, st_opts, st_save, and st_versions
to pin versioning to "content" and then proceed with the three save/check steps.

---

Nitpick comments:
In `@copilot_logs/LOG_fix_versioning.md`:
- Line 51: Update the section header string "To Do List" to the hyphenated form
"To-Do List" to match the requested style; locate the header text "To Do List"
in the document and replace it with "To-Do List" so the section uses the
hyphenated wording.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 95eecf99-5bf6-4c5b-b72f-b4a4751456ac

📥 Commits

Reviewing files that changed from the base of the PR and between 56c4949 and 2ce6ef8.

📒 Files selected for processing (8)
  • DESCRIPTION
  • NEWS.md
  • R/IO_core.R
  • R/aaa.R
  • copilot_logs/LOG_fix_versioning.md
  • man/dot-st_resolve_and_normalize.Rd
  • man/dot-st_resolve_file_path.Rd
  • tests/testthat/test-should-save.R
💤 Files with no reviewable changes (3)
  • man/dot-st_resolve_file_path.Rd
  • R/aaa.R
  • man/dot-st_resolve_and_normalize.Rd

Comment on lines +83 to +115
test_that("st_save correctly skips saving identical content (regression test)", {
skip_on_cran()
td <- withr::local_tempdir()
st_init(td)
st_opts(default_format = "qs2")

df <- data.frame(x = 1:5, y = letters[1:5])

# First save
r1 <- st_save(df, "test.qs2", verbose = FALSE)
expect_false(is.null(r1$version_id))
v1 <- r1$version_id

# Second save with IDENTICAL content - should be skipped
r2 <- st_save(df, "test.qs2", verbose = FALSE)
expect_true(r2$skipped)
expect_equal(r2$reason, "no_change_policy")

# Verify only one version exists
versions <- st_versions("test.qs2")
expect_equal(nrow(versions), 1)
expect_equal(versions$version_id[1], v1)

# Third save with CHANGED content - should create new version
df_changed <- data.frame(x = 6:10, y = letters[6:10])
r3 <- st_save(df_changed, "test.qs2", verbose = FALSE)
expect_false(is.null(r3$version_id))
expect_false(r3$version_id == v1)

# Verify two versions exist now
versions2 <- st_versions("test.qs2")
expect_equal(nrow(versions2), 2)
})
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Make this regression test deterministic by pinning versioning mode.

This test relies on global st_opts() state; explicitly setting versioning = "content" would ensure it always validates the intended default-mode bug path.

Suggested hardening
 test_that("st_save correctly skips saving identical content (regression test)", {
   skip_on_cran()
   td <- withr::local_tempdir()
   st_init(td)
   st_opts(default_format = "qs2")
+  st_opts(versioning = "content")
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
test_that("st_save correctly skips saving identical content (regression test)", {
skip_on_cran()
td <- withr::local_tempdir()
st_init(td)
st_opts(default_format = "qs2")
df <- data.frame(x = 1:5, y = letters[1:5])
# First save
r1 <- st_save(df, "test.qs2", verbose = FALSE)
expect_false(is.null(r1$version_id))
v1 <- r1$version_id
# Second save with IDENTICAL content - should be skipped
r2 <- st_save(df, "test.qs2", verbose = FALSE)
expect_true(r2$skipped)
expect_equal(r2$reason, "no_change_policy")
# Verify only one version exists
versions <- st_versions("test.qs2")
expect_equal(nrow(versions), 1)
expect_equal(versions$version_id[1], v1)
# Third save with CHANGED content - should create new version
df_changed <- data.frame(x = 6:10, y = letters[6:10])
r3 <- st_save(df_changed, "test.qs2", verbose = FALSE)
expect_false(is.null(r3$version_id))
expect_false(r3$version_id == v1)
# Verify two versions exist now
versions2 <- st_versions("test.qs2")
expect_equal(nrow(versions2), 2)
})
test_that("st_save correctly skips saving identical content (regression test)", {
skip_on_cran()
td <- withr::local_tempdir()
st_init(td)
st_opts(default_format = "qs2")
st_opts(versioning = "content")
df <- data.frame(x = 1:5, y = letters[1:5])
# First save
r1 <- st_save(df, "test.qs2", verbose = FALSE)
expect_false(is.null(r1$version_id))
v1 <- r1$version_id
# Second save with IDENTICAL content - should be skipped
r2 <- st_save(df, "test.qs2", verbose = FALSE)
expect_true(r2$skipped)
expect_equal(r2$reason, "no_change_policy")
# Verify only one version exists
versions <- st_versions("test.qs2")
expect_equal(nrow(versions), 1)
expect_equal(versions$version_id[1], v1)
# Third save with CHANGED content - should create new version
df_changed <- data.frame(x = 6:10, y = letters[6:10])
r3 <- st_save(df_changed, "test.qs2", verbose = FALSE)
expect_false(is.null(r3$version_id))
expect_false(r3$version_id == v1)
# Verify two versions exist now
versions2 <- st_versions("test.qs2")
expect_equal(nrow(versions2), 2)
})
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/testthat/test-should-save.R` around lines 83 - 115, The test relies on
global st_opts state so make it deterministic by explicitly setting the
versioning mode before saves; call st_opts(versioning = "content",
default_format = "qs2") (or at minimum set versioning = "content") near the
start of the test (before the first st_save) so the behavior of st_save,
st_versions and skipped/no_change_policy checks is consistent; update the test
that uses st_init, st_opts, st_save, and st_versions to pin versioning to
"content" and then proceed with the three save/check steps.

@randrescastaneda randrescastaneda merged commit 23e23ee into master Mar 4, 2026
3 checks passed
@randrescastaneda randrescastaneda deleted the fix_versioning branch March 4, 2026 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants