% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/cff_git_hook.R
\encoding{UTF-8}
\name{cff_git_hook}
\alias{cff_git_hook}
\alias{cff_git_hook_install}
\alias{cff_git_hook_remove}
\title{Use a git pre-commit hook \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}}}
\usage{
cff_git_hook_install()

cff_git_hook_remove()
}
\value{
Invisible. This function is called for its side effects.
}
\description{
Install a
\href{https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks#_committing_workflow_hooks}{pre-commit hook}
that reminds you to update your \code{CITATION.cff} file. This is a wrapper around
\code{\link[usethis:use_git_hook]{usethis::use_git_hook()}}.
}
\details{
This function installs a pre-commit hook using
\code{\link[usethis:use_git_hook]{usethis::use_git_hook()}}.

A pre-commit hook is a script that identifies simple issues before
submission to code review. This pre-commit hook warns you if any of the
following conditions are met:
\itemize{
\item You included your \code{DESCRIPTION} or \code{inst/CITATION} file in a commit but
did not include your \code{CITATION.cff}, and the \code{CITATION.cff} file is
"older" than your \code{DESCRIPTION} or \code{inst/CITATION} file.
\item You updated your \code{CITATION.cff} but did not include it in
your commit.
}
}
\section{A word of caution}{
The pre-commit hook may prevent you from committing if you are not updating
your \code{CITATION.cff}. However, the detection mechanism is not perfect and may
be triggered even if you have attempted to update your \code{CITATION.cff} file.

This typically occurs when you have updated your \code{DESCRIPTION} or
\code{inst/CITATION} files, but those changes do not affect your
\code{CITATION.cff} file (for example, you are adding new dependencies).

In those cases, you can override the check by running
\verb{git commit --no-verify} in the terminal.

If you are using \strong{RStudio}, you can also run this command from an \strong{R}
script by selecting that line and sending it to the terminal using:
\itemize{
\item Windows & Linux: \code{Ctrl+Alt+Enter}.
\item Mac: \code{Cmd+Option+Return}.
}
}

\section{Removing the git pre-commit hook}{
You can remove the pre-commit hook using \code{cff_git_hook_remove()}.
}

\examples{
\dontrun{
cff_git_hook_install()
}

}
\seealso{
\itemize{
\item \code{\link[usethis:use_git_hook]{usethis::use_git_hook()}}, which is the underlying function used by
\code{cff_git_hook_install()}.
\item \code{\link[usethis:use_git]{usethis::use_git()}} and related function of \CRANpkg{usethis} for using
Git with \strong{R} packages.
}

Other Git/GitHub helpers provided by \CRANpkg{cffr}:
\code{\link[=cff_gha_update]{cff_gha_update()}}
}
\concept{git}
