-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGitPushFunctions.R
More file actions
43 lines (37 loc) · 1.01 KB
/
GitPushFunctions.R
File metadata and controls
43 lines (37 loc) · 1.01 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
#install.packages("git2r")
#Credit to https://stackoverflow.com/questions/55432420/how-can-i-commit-changes-to-github-from-within-a-r-script
if (!require(git2r)) install.packages('git2r')
if (!require(drat)) install.packages('drat')
library(git2r)
library(drat)
gitstatus <- function(dir = getwd()){
cmd_list <- list(
cmd1 = tolower(substr(dir,1,2)),
cmd2 = paste("cd",dir),
cmd3 = "git status"
)
cmd <- paste(unlist(cmd_list),collapse = " & ")
shell(cmd)
}
gitadd <- function(dir = getwd()){
cmd_list <- list(
cmd1 = tolower(substr(dir,1,2)),
cmd2 = paste("cd",dir),
cmd3 = "git add --all"
)
cmd <- paste(unlist(cmd_list),collapse = " & ")
shell(cmd)
}
gitcommit <- function(msg = "commit from Rstudio", dir = getwd()){
cmd = sprintf("git commit -m\"%s\"",msg)
system(cmd)
}
gitpush <- function(dir = getwd()){
cmd_list <- list(
cmd1 = tolower(substr(dir,1,2)),
cmd2 = paste("cd",dir),
cmd3 = "git push"
)
cmd <- paste(unlist(cmd_list),collapse = " & ")
shell(cmd)
}