Skip to content

Allow a root for deps-in-desc #432

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

Merged
merged 7 commits into from
Aug 2, 2022
Merged

Allow a root for deps-in-desc #432

merged 7 commits into from
Aug 2, 2022

Conversation

lorenzwalthert
Copy link
Owner

No description provided.

@@ -16,6 +18,8 @@ pre_installed <- c(
)

arguments <- docopt::docopt(doc)
arguments$files <- normalizePath(arguments$files) # because working directory changes to root
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know if we want to normalize these paths. Doesn't that remove the purpose of this --root option?

If we normalize files before setwd(normalizePath(arguments$root)), then this hook called like below:

deps-in-desc --root "rpkg" FILE1

will process rpkg/../FILE1

However, I think we would want it to process rpkg/FILE1

Therefore, this would require:

deps-in-desc --root "rpkg" rpkg/FILE1

Am I missing something?

Copy link
Owner Author

Choose a reason for hiding this comment

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

I am not sure I can follow, but pre-commit will generate a call where the paths to the files are relative to the git root. Like this

Rscript inst/hooks/exported/deps-in-desc.R --root rpkg rpkg/file1 

So we need to make these paths absolute before changing the working directory, otherwise information is lost. Afterwards, it does not matter anymore if the paths are absoulte or if we convert back to relative. The working directory change is only for ensuring desc::desc() finds the DESCRIPTION file. And it could also be solved without changing the working directory in the first place but I think the current approach genearlised better to other situations.

Copy link
Owner Author

Choose a reason for hiding this comment

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

I just pushed a fix for tests because previously, the R source file to test was not in the R sub directory, but one level above. This also works, i.e. the R source file can be outside of the R package root to test if the dependencies are captured, but probably that's not what we want to test.

Copy link
Contributor

@TNonet TNonet Aug 2, 2022

Choose a reason for hiding this comment

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

I am not sure I can follow, but pre-commit will generate a call where the paths to the files are relative to the git root. Like this

Rscript inst/hooks/exported/deps-in-desc.R --root rpkg rpkg/file1 

So we need to make these paths absolute before changing the working directory, otherwise information is lost. Afterwards, it does not matter anymore if the paths are absoulte or if we convert back to relative. The working directory change is only for ensuring desc::desc() finds the DESCRIPTION file. And it could also be solved without changing the working directory in the first place but I think the current approach genearlised better to other situations.

Ah, I thought the files were being passed in by the user and not from precommit itself. I now understand the need to normalize the files.

@lorenzwalthert
Copy link
Owner Author

Now, there are remaining hooks to adapt:

  • roxygenize
  • use tidy desc
  • codemeta-description-updated

@lorenzwalthert
Copy link
Owner Author

@TNonet are you interested in contributing?

@TNonet
Copy link
Contributor

TNonet commented Aug 2, 2022

Hi @lorenzwalthert,

Yes, thank you for the patience/support. I worked on this (#436) morning.

I am unsure what is wrong with my new roxygenize tests, but I will take another iteration tomorrow.

@lorenzwalthert lorenzwalthert merged commit c8d6e76 into main Aug 2, 2022
@lorenzwalthert
Copy link
Owner Author

Ok, great. I go ahead and merge this. Please rebase your branch on this if possible.

@lorenzwalthert lorenzwalthert deleted the issue-429 branch August 2, 2022 14:33
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