Skip to content

Fixing the return value of rename_variable() on Windows#83

Merged
ThierryO merged 5 commits into0.5.2from
rename_variable
Feb 25, 2026
Merged

Fixing the return value of rename_variable() on Windows#83
ThierryO merged 5 commits into0.5.2from
rename_variable

Conversation

@florisvdh
Copy link
Collaborator

@florisvdh florisvdh commented Feb 18, 2026

Description

This PR adds some fixes related to the return value of rename_variable().

  • In the documentation, the description of the return value was wrong (NULL).
  • On Windows it has been observed that the root remains included in the result, despite remove_root() was called. During debugging on Windows, it was seen that Windows-specific pattern mismatches occurred between the root and file arguments of remove_root(). These could be "\\" vs. "/" as well as user directory abbreviations. Applying normalizePath() on both inputs of remove_root() before calling the latter, similar to the way this is handled in write_vc() (where the problem doesn't pop up), solved it.
  • A test has been added to verify that the root is not part of the resulting file vector.

I'm pushing this in two steps, hoping to see failure of the tests in Windows first, then succes after adding the commit that fixes behaviour.

@florisvdh
Copy link
Collaborator Author

The force-push was to correct the commit message.

In Windows, this avoids that pattern mismatches occur between root and
file. Before, this could lead to not removing the root part from the returned
vector.
@florisvdh
Copy link
Collaborator Author

As hoped, the Windows check of d6ab4ad demonstrates the issue:

══ Failed tests ════════════════════════════════════════════════════════════════
── Failure ('test_g_rename_variable.R:249:3'): rename_variable() shows no root in returned file names ──
Expected every element of `result` not to match regexp "git2rdata-rename-".
Actual text:
✖ │ C:/Users/RUNNER~1/AppData/Local/Temp/RtmpE1UI4b/working_dir/RtmpCaFXlZ/git2rdata-rename-276027fb75c5/unsorted.tsv
✖ │ C:/Users/RUNNER~1/AppData/Local/Temp/RtmpE1UI4b/working_dir/RtmpCaFXlZ/git2rdata-rename-276027fb75c5/unsorted.yml

It is fixed by f486662.

florisvdh added a commit to inbo/n2khab-preprocessing that referenced this pull request Feb 19, 2026
The proposed git2rdata update fixed a Windows problem with rename_variables();
see ropensci/git2rdata#83.
Copy link
Member

@ThierryO ThierryO left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. I'll fix the other issues raised by checklist.

@ThierryO ThierryO changed the base branch from main to 0.5.2 February 25, 2026 11:24
@ThierryO ThierryO merged commit d06a99a into 0.5.2 Feb 25, 2026
7 checks passed
@ThierryO ThierryO deleted the rename_variable branch February 25, 2026 11:25
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