Add timestamp and sha string to a file name
add_version.Rd
An alternative to version data is to name it using the sha (unique identifier) of the code using to generate or process the data and the time at which the data was generated or processed. This function adds this information, a version identifier, to a file name (character string)
Details
The SHA information is retrieved using git2r::sha. If the code is not
running in a context aware of a git repository (for example when code is
running inside a container) then this function attempts to get the sha from
the environment variable GITHUB_SHA
. If both of these methods fail, no sha
versioning is added.
Examples
if (git2r::in_repository()) {
add_version("my_file", "csv")
}
#> [1] "my_file__20241112222209_a15d718__.csv"