Automatically commit any changes made be development helper packages.
Check whether some code will cause changes to git status
in the working directory.
auto_commit(after_code = NULL, ...)check_clean_tree(code = NULL, path = getwd(), before_code = NULL)
[character(1)]
Giving what happens when the working tree is unclean after code
is evaluated:
NULL
to throw an error or
"commit"
to commit the changes.
Defaults to NULL
, which just thinly wraps check_clean_tree()
.
Arguments passed on to check_clean_tree
The code to execute.
Defaults to NULL
.
The directory in which to execute the code.
Defaults to getwd()
.
[character(1)]
Giving what happens when the working tree is already unclean before code
is evaluated:
NULL
(recommended default), in which case if is.act()
, then "commit"
, otherwise throw an error.
"stash"
to git stash push
all changes before, and git stash pop
them after code
is run (not recommended).
"commit"
to git add .; git commit -m "commit to cleanup"
all changes before code
is run and git reset HEAD
them after code
is run (not recommended).
The code to execute.
Defaults to NULL
.
The directory in which to execute the code.
Defaults to getwd()
.
[character(1)]
Giving what happens when the working tree is already unclean before code
is evaluated:
NULL
(recommended default), in which case if is.act()
, then "commit"
, otherwise throw an error.
"stash"
to git stash push
all changes before, and git stash pop
them after code
is run (not recommended).
"commit"
to git add .; git commit -m "commit to cleanup"
all changes before code
is run and git reset HEAD
them after code
is run (not recommended).
[list()]
of lists of git command feedback or [NULL]
when there were no changes (invisible).
[character(1)]
The git status
results or TRUE
if no diffs.
This function will commit all changes caused by code
to the repository.
Running this in CI/CD can save some time, but can also cause unexpected behavior and pollute the commit history with derivative changes.
The contents of path
will be copied to a temporary directory, where a git repository will be initiated and the code
will be executed.
There will never be any changes to path
.
If path
or its subdirectories contain a .gitignore
, it will be respected.
This function is modelled checkmate.