Miscellaneous R functions which I load in my .Rprofile
, including functions to
One function increment_dev_version()
is an alternative version of
usethis::use_dev_version()
,
but adapted to my workflow of incrementing the fourth component of version
numbers for every single commit. I have this function aliased to incr="Rscript -e 'mpmisc::increment_dev_version()'"
, so simply have to type incr
to
automatically increment my version and update codemeta.json
(if that file
exists).
I mirror many repositories on various git remote services, including
Sourcehut, GitLab,
BitBucket, and GitHub. The
add_git_remotes()
function automatically adds the appropriate remote
entries for any locations in which a repository is mirrored. I use a single
git push
alias to mirror that command to all listed remotes. This
add_git_remotes()
function saves me the trouble of having to manually specify
these for each new repository.
I use the precommit
package
to implement pre-commit hooks, including a personalised hook to ensure that the
development version number has been incremented using the above
increment_dev_version()
function on each commit. This requires installing the
pre-commit
library, and the precommit
R
package. This repository then
has both:
.pre-commit-config.yaml
modified from the original version inprecommit
R package, primarily through the addition of:- id: description version
name: Version has been incremeneted in DESCRIPTION
entry: inst/precommit/description
language: script
inst/precommit/description
file which checks first thatDESCRIPTION
has been modified, and secondly that the modification includes"Version"
.In practice, my description
hook lives in a general location at
~/bin/precommit/description
rather than within any particular repo, with the
entry
value reflecting this location.