Skip to contents

After pii_redact_files() has written a redacted copy beside each flagged file, adds each original to its repository's .gitignore, so the clean copy can be committed and the original cannot be by accident. Each rule names one file. Every rule added is checked with git check-ignore, and a redacted copy that an existing rule would also hide is reported.

Usage

pii_ignore_originals(report)

Arguments

report

The result of pii_redact_files().

Value

A tibble with one row per redacted original: source, the gitignore file changed, the action taken (added, already ignored or not in a git repository), whether the original is_tracked, and detail.

Details

It does not rewrite history. An original already committed stays in the repository's past, and stays tracked until removed with git rm --cached; such files are reported with is_tracked.

Examples

project <- file.path(tempdir(), "survey_project")
dir.create(project)
system2("git", c("init", "-q", project))
write.csv(
  data.frame(email = paste0("person", 1:20, "@example.org")),
  file.path(project, "survey.csv"),
  row.names = FALSE
)
report <- pii_redact_files(project)
#> Wrote 1 redacted copy.
#> ℹ The originals are unchanged and still hold the personal data.
pii_ignore_originals(report)
#> Added 1 original to .gitignore.
#> # A tibble: 1 × 5
#>   source                                    gitignore   action is_tracked detail
#>   <chr>                                     <chr>       <chr>  <lgl>      <chr> 
#> 1 /tmp/RtmpeoiXV6/survey_project/survey.csv /tmp/Rtmpe… added  FALSE      NA    
readLines(file.path(project, ".gitignore"))
#> [1] "# Originals holding personal data; redacted copies sit beside them (piinata)"
#> [2] "/survey.csv"                                                                 
unlink(project, recursive = TRUE)