This vignette provides detailed documentation and usage examples for the three diff functions in the qctools package: diffPreviousVersions(), diffQced(), and diffOriginal(). These functions facilitate the visual comparison of different versions of files within your project, aiding in quality control and code review processes.

Table of Contents


gitLog()

The gitLog() function returns the commit hash, last author and datetime of all commits for a specified file. The commit history is useful for comparing different versions of a file.

Usage

Retrieve Full Commit History
gitLog("script/data-assembly.R")

Output:

file last_commit last_author last_datetime
script/data-assembly.R eb96eeb Alice Johnson 2024-11-21 15:45:00
script/data-assembly.R 6f05a8b John Smith 2024-11-20 12:30:00
script/data-assembly.R c4f837e Jane Doe 2024-11-19 10:00:00
Retrieve Only the Last Commit
gitLog("script/data-assembly.R", last_rev_only = TRUE)

Output:

file last_commit last_author last_datetime
script/data-assembly.R eb96eeb Alice Johnson 2024-11-21 15:45:00

diffPreviousVersions()

The diffPreviousVersions() function visually identifies changes between two versions of a file, highlighting additions, deletions, and modifications.

Usage

Compare with a Specific Previous Commit
diffPreviousVersions(
  file = "script/data-assembly.R",
  previous_version = "6f05a8b",
  side_by_side = FALSE
)

Output:

Output of diffPreviousVersions(): green text indicates modified code, red text indicates deleted code.
Output of diffPreviousVersions(): green text indicates modified code, red text indicates deleted code.

diffQced()

The diffQced() function identifies differences from the latest version of a file with the most recent QCed (quality-controlled) version, visually highlighting any changes that need re-evaluation.

Usage

Compare with the Last QCed Version
diffQced("script/data-assembly.R")

Output:

Output of diffQced(): green text indicates modified code, red text indicates deleted code.
Output of diffQced(): green text indicates modified code, red text indicates deleted code.

diffOriginal()

The diffOriginal() function identifies differences from the latest version of a file with the original (e.g. template) version, visually highlighting any changes.

Usage

Compare with the Original Version
diffOriginal("script/data-assembly.R")

Additional Notes

  • Customization: Users can customize the display of diffs by adjusting the side_by_side and ignore_white_space parameters as needed.