forked from r-lib/devtools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinfrastructure-git.R
82 lines (68 loc) · 2.4 KB
/
infrastructure-git.R
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
#' @rdname devtools-deprecated
#' @export
use_git <- function(message = "Initial commit", pkg = ".") {
.Deprecated("usethis::use_git()", package = "devtools")
warn_unless_current_dir(pkg)
usethis::use_git(message = message)
}
# This is still used internally in the devtools tests
use_git_with_config <- function(message, pkg, add_user_config = FALSE, quiet = FALSE) {
pkg <- as.package(pkg)
if (uses_git(pkg$path)) {
message("* Git is already initialized")
return(invisible())
}
if (!quiet) {
message("* Initialising repo")
}
r <- git2r::init(pkg$path)
if (add_user_config) {
git2r::config(r, global = FALSE, user.name = "user", user.email = "[email protected]")
}
use_git_ignore(c(".Rproj.user", ".Rhistory", ".RData"), pkg = pkg, quiet = quiet)
if (!quiet) {
message("* Adding files and committing")
}
paths <- unlist(git2r::status(r))
git2r::add(r, paths)
git2r::commit(r, message)
invisible()
}
#' @rdname devtools-deprecated
#' @export
use_github <- function(auth_token = github_pat(), private = FALSE, pkg = ".",
host = "https://api.github.com",
protocol = c("ssh", "https"), credentials = NULL, ...) {
.Deprecated("usethis::use_github()", package = "devtools")
warn_unless_current_dir(pkg)
usethis::use_github(
auth_token = auth_token, private = private, host = host,
protocol = protocol, credentials = credentials, ...
)
}
#' @rdname devtools-deprecated
#' @export
use_git_hook <- function(hook, script, pkg = ".") {
.Deprecated("usethis::use_git_hook()", package = "devtools")
warn_unless_current_dir(pkg)
usethis::use_git_hook(hook = hook, script = script)
}
# This is still used internally in the devtools tests
use_git_ignore <- function(ignores, directory = ".", pkg = ".", quiet = FALSE) {
pkg <- as.package(pkg)
paths <- paste0("`", ignores, "`", collapse = ", ")
if (!quiet) {
message("* Adding ", paths, " to ", file.path(directory, ".gitignore"))
}
path <- file.path(pkg$path, directory, ".gitignore")
union_write(path, ignores)
invisible(TRUE)
}
#' @rdname devtools-deprecated
#' @export
use_github_links <- function(pkg = ".", auth_token = github_pat(),
host = "https://api.github.com") {
.Deprecated("usethis::use_github_links()", package = "devtools")
warn_unless_current_dir(pkg)
usethis::use_github_links(auth_token = auth_token, host = host)
}