Skip to content

Provides functionality for system-level git commands from within R.

Usage

git(..., echo_cmd = TRUE)

is_git()

git_version()

git_checkout(branch = NULL)

Arguments

...

Additional arguments passed to the system command-line git <command> [<args>] call.

echo_cmd

Logical. Whether to print the command to run to the console.

branch

Character. The name of a branch, typically a feature branch.

Value

git(): The system call ... invisibly.

is_git(): Logical.

git_version(): Character. The system version of git.

git_checkout(): NULL ... invisibly.

Functions

  • git(): executes a git command line call from within R.

  • is_git(): is current working directory a git repository?

  • git_version(): gets the version of git in use.

  • git_checkout(): git checkout as a branch if doesn't exist. Branch oriented workflow for switching between branches.

Examples

if (FALSE) {
git("status", "-s")

get_commit_msgs()

get_commit_msgs(n = 3)

get_pr_msgs()

# lint most recent 3 commit message
lapply(get_commit_msgs(n = 3), lint_commit_msg)

# for a PR `branch` -> `remotes/origin/{main,master}`
lapply(get_pr_msgs(), lint_commit_msg)           # current branch
lapply(get_pr_msgs("feature"), lint_commit_msg)  # `feature` branch

get_recent_tag()
}