Manually Ignore Files or Directories in .gitignore and .Rbuildignore
projr_ignore.RdThese functions allow manual addition of files and directories to the
.gitignore and .Rbuildignore files, outside of the automatic management
provided by the projr package.
projr_ignore: General function to add both files and directories to both.gitignoreand.Rbuildignore. If a path does not exist, it is treated as a file.projr_ignore_dir: Specifically adds directories to both.gitignoreand.Rbuildignore.projr_ignore_file: Specifically adds files to both.gitignoreand.Rbuildignore.projr_ignore_dir_gitandprojr_ignore_file_git: Add directories or files explicitly to.gitignore.projr_ignore_dir_rbuildandprojr_ignore_file_rbuild: Add directories or files explicitly to.Rbuildignore.
Usage
projr_ignore(ignore, force_create = TRUE)
projr_ignore_dir(ignore, force_create = TRUE)
projr_ignore_file(ignore)
projr_ignore_file_git(ignore, force_create = TRUE)
projr_ignore_dir_git(ignore, force_create = TRUE)
projr_ignore_file_rbuild(ignore, force_create = TRUE)
projr_ignore_dir_rbuild(ignore, force_create = TRUE)Arguments
- ignore
A character vector of file or directory paths to be ignored. Paths must be valid non-empty strings.
- force_create
logical. If
FALSE, then the function will only add to the corresponding ignore file (.gitignore/.Rbuildignore) if it already exists, OR if it is warranted (i.e. if there is a Git repository or DESCRIPTION file, respectively). IfTRUE, then the function will create the ignore file if it does not exist, even if there is no Git repository or DESCRIPTION file, and will add the specified paths to it. Default isTRUE.
Value
Invisibly returns TRUE if the operation succeeds, or FALSE if the input
contains invalid (empty) paths.
Details
These functions provide fine-grained control for cases where users want to
manually ignore specific paths permanently. They do not interact with the
automated ignore management system of projr.
Non-existent paths provided to
projr_ignoreare assumed to be files.For
.gitignore, directories are automatically appended with/**if missing, ensuring proper Git ignore syntax.For
.Rbuildignore, paths are converted to regular expressions usingglob2rxfor compatibility with R's build tools.
See also
projr_ignore_auto for dynamically managed ignore entries, and projr_unignore_manual
for forcing certain paths to not be ignored.
Examples
# Manually ignore files and directories
projr_ignore(c("output", "tempfile.log"))
# Specifically ignore directories
projr_ignore_dir("data")
# Specifically ignore files
projr_ignore_file("README.md")