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 80 81 82 83 84 85
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/contributions.R
\name{contributions}
\alias{contributions}
\title{Contributions}
\usage{
contributions(
repo = ".",
breaks = c("month", "year", "quarter", "week", "day"),
by = c("commits", "author")
)
}
\arguments{
\item{repo}{a path to a repository or a \code{git_repository}
object. Default is '.'}
\item{breaks}{Default is \code{month}. Change to year, quarter,
week or day as necessary.}
\item{by}{Contributions by "commits" or "author". Default is "commits".}
}
\value{
A \code{data.frame} with contributions.
}
\description{
See contributions to a Git repo
}
\examples{
\dontrun{
## Create directories and initialize repositories
path_bare <- tempfile(pattern="git2r-")
path_repo_1 <- tempfile(pattern="git2r-")
path_repo_2 <- tempfile(pattern="git2r-")
dir.create(path_bare)
dir.create(path_repo_1)
dir.create(path_repo_2)
repo_bare <- init(path_bare, bare = TRUE)
## Clone to repo 1 and config user
repo_1 <- clone(path_bare, path_repo_1)
config(repo_1, user.name = "Alice", user.email = "alice@example.org")
## Add changes to repo 1 and push to bare
lines <- "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do"
writeLines(lines, file.path(path_repo_1, "test.txt"))
add(repo_1, "test.txt")
commit(repo_1, "First commit message")
## Add more changes to repo 1
lines <- c(
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do",
"eiusmod tempor incididunt ut labore et dolore magna aliqua.")
writeLines(lines, file.path(path_repo_1, "test.txt"))
add(repo_1, "test.txt")
commit(repo_1, "Second commit message")
## Push to bare
push(repo_1, "origin", "refs/heads/master")
## Clone to repo 2
repo_2 <- clone(path_bare, path_repo_2)
config(repo_2, user.name = "Bob", user.email = "bob@example.org")
## Add changes to repo 2
lines <- c(
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do",
"eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad",
"minim veniam, quis nostrud exercitation ullamco laboris nisi ut")
writeLines(lines, file.path(path_repo_2, "test.txt"))
add(repo_2, "test.txt")
commit(repo_2, "Third commit message")
## Push to bare
push(repo_2, "origin", "refs/heads/master")
## Pull changes to repo 1
pull(repo_1)
## View contributions by day
contributions(repo_1)
## View contributions by author and day
contributions(repo_1, by = "author")
}
}
|