Skip to content

Commit

Permalink
Merge pull request #105 from metrumresearchgroup/file-delete
Browse files Browse the repository at this point in the history
Add fileDelete function
  • Loading branch information
andersone1 authored Oct 31, 2024
2 parents 01ea408 + fa5c0b2 commit 0ebe9b1
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 0 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export(logAccept)
export(logAssign)
export(logCreate)
export(logPending)
export(logRemove)
export(logSummary)
export(renderQCSummary)
export(repoHistory)
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## New features and changes

- `logRemove` added to package to assist with removing files from the QC log. (#105)

- `diffFiles` can now display the entire file that is being diffed. (#115)

- Added `repoHistory` function to return history of all commits in the repository. (#116)
Expand Down
24 changes: 24 additions & 0 deletions R/logRemove.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#' Remove file from QClog
#'
#' @description
#' This function facilitates deleting a file from the QClog.csv file.
#' When run, all rows associated with the file will be deleted and
#' removed from the QC log.
#'
#' @param .filepath current file path of file to be removed
#'
#' @export
logRemove <- function(.filepath) {

qclog <- logRead()
qclog2 <- qclog[qclog$file != .filepath, ]

# Check current file path exists
if(nrow(qclog) == nrow(qclog2)) {
stop(paste0(.filepath, " does not exist in QClog.csv"))
}

cli::cli_alert_info(glue::glue("Deleted '{.filepath}' from QClog.csv"))

logWrite(qclog2, file = "QClog.csv")
}
1 change: 1 addition & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ reference:
- svnLog
- svnExport
- demoRepo
- logRemove
- repoHistory
16 changes: 16 additions & 0 deletions man/logRemove.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions tests/testthat/test-logRemove.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
with_demoRepo({

testthat::test_that("logRemove removes the file from the QClog", {

qclog <- logRead()
expect_true(nrow(qclog[qclog$file == "script/data-assembly.R",]) > 0)

logRemove("script/data-assembly.R")
qclog2 <- logRead()

expect_true(nrow(qclog2[qclog2$file == "script/data-assembly.R",]) == 0)
})
})



0 comments on commit 0ebe9b1

Please sign in to comment.