Skip to content

FR: More flexible repo structure #290

@katrinabrock

Description

@katrinabrock

Current Behavior

I'm not sure if this intentional or not: When the package is in a git repo, but the git root and package root are different, pkgcheck only uses the user-provided path to find the git repo, then uses its own logic to search within the repo for the package. If the user provides the exact subfolder within the repo where the package is located, this is ignored.

I didn't see this "search within repo" logic documented anywhere, but maybe I missed it. Basically, pkgcheck will work if the git repo root and the package root are the same OR if there is exactly one subfolder of the repo root that contains an R package.

In particular, if there is more than one subfolder that contains an R package or if the R package you want to check is deeper inside the repo, pkgcheck will not run. This is demonstrated below:

MRE
############
# First, set up git repo and verify basic case working
############

mkdir tmp
cd tmp
git init
echo 'Package: ' > DESCRIPTION
R -q -e 'pkgcheck:::convert_path(".")'
# works

#cleanup
rm DESCRIPTION

############
# Next, try adding R packages in subdirectories
############

# add a package in a subdirectory
mkdir mypkg1
echo 'Package: ' > mypkg1/DESCRIPTION
R -q -e 'pkgcheck:::convert_path("./mypkg1/")'
# works

# add another package in a subdirectory
mkdir mypkg2
echo 'Package: ' > mypkg2/DESCRIPTION
R -q -e 'pkgcheck:::convert_path("./mypkg2/")'
# fails
R -q -e 'pkgcheck:::convert_path("./mypkg2/")'
# fails

# clean up
rm mypkg1/DESCRIPTION mypkg2/DESCRIPTION
rmdir mypkg1 mypkg2

############
# Finally try, adding a package to a sub-sub-directory
############

mkdir allmypkgs
mkdir allmypkgs/mypkg3
echo 'Package: ' > allmypkgs/mypkg3/DESCRIPTION
R -q -e 'pkgcheck:::convert_path("./allmypkgs/mypkg3/")'

# full cleanup
cd ..
rm -r tmp

A (granted unlikely scenario), if the the user has

myrepo
myrepo/myworkingpackage
myrepo/anotherfolder/mybrokenpackage

where myrepo is the repo root and myworkingpackage and mybrokenpackage both contain packages, then when the user runspkgcheck("myrepo/anotherfolder/mybrokenpackage"), it will result in checking myworkingpackage rather than mybrokenpackage.

Desired behavior

If this limitation on where in the repo a package can be located is intentional, it would at least be nice to have it documented in the pkgcheck::pkgcheck() reference. It does say that path should be the path to the repo, not to the pkg root, but then in the example it says /path/to/package/root which implies they're the same. Documenting more explicitly what setups are supported and not supported would be helpful.

If this limitation is not intentional, it would be nice to update the logic so if the user provides a path to a valid package anywhere in their git repo, it will be checked.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions