forked from ropensci/cffr
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcff_git_hook.Rd
More file actions
79 lines (70 loc) · 2.75 KB
/
Copy pathcff_git_hook.Rd
File metadata and controls
79 lines (70 loc) · 2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
% 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, when you add 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 \R
script by selecting that line and sending it to the terminal with:
\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 functions of \CRANpkg{usethis} for using
Git with \R packages.
}
Keep \file{CITATION.cff} up to date:
\code{\link[=cff_gha_update]{cff_gha_update()}}
}
\concept{git}