-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjoin-fun.R
92 lines (78 loc) · 3.11 KB
/
join-fun.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
83
84
85
86
87
88
89
90
91
92
url_prefix <- function() {
"https://github.com/Reproducible-Science-Curriculum"
}
fetch_lessons <- function(lessons, dest) {
if (file.exists(dest)) {
stop("Destination already exists")
}
dir.create(dest, FALSE, TRUE)
system(paste("git init", dest))
url_prefix <- url_prefix()
for (i in lessons) {
system(sprintf("git clone --branch gh-pages %s/%s.git %s/%s", url_prefix, i, dest, i))
system(sprintf("cd %s/%s; git checkout -b master origin/master", dest, i))
}
}
copy_gh_pages <- function(lessons, dest) {
writeLines("www", file.path(dest, ".gitignore"))
system(sprintf("git clone %s %s/www", dest, dest))
system(sprintf("cd %s/www; git checkout --orphan gh-pages", dest))
system(sprintf("cd %s/www; git remote rm origin", dest))
for (i in lessons) {
system(sprintf("cd %s/www; git clone --branch gh-pages ../%s", dest, i))
}
}
drop_lesson_git <- function(lessons, dest) {
for (i in lessons) {
unlink(sprintf("%s/www/%s/.git", dest, i), recursive=TRUE)
unlink(sprintf("%s/%s/.git", dest, i), recursive=TRUE)
}
}
merge_tests <- function(lessons, dest) {
## Continuous integration
dat <- do.call("rbind",
lapply(file.path(dest, lessons, ".description"), read.dcf))
depends <- paste(unique(unlist(strsplit(dat[,"Depends"], ",\\s*"))),
collapse=", ")
writeLines(paste("Depends: ", depends),
file.path(dest, ".description"))
file.copy("ci/appveyor.yml", dest)
file.copy("ci/.travis.yml", dest)
## Now, write an R file that will run each test.
library(whisker)
lessons_str <- paste(sprintf('"%s"', lessons), collapse=", ")
writeLines(whisker.render(readLines("ci/ci_tests.R.whisker"),
list(lessons=lessons_str)),
file.path(dest, ".ci_tests.R"))
}
combined_setup_root <- function(dest) {
files <- dir("content/gh-pages", full.names=TRUE)
file.copy(files, file.path(dest, "www"), recursive=TRUE)
files <- dir("content/master", full.names=TRUE)
file.copy(files, file.path(dest), recursive=TRUE)
}
combined_commit <- function(dest) {
system(sprintf("cd %s/www; git add .; git commit -m 'merge repos'", dest))
system(sprintf("cd %s; git add .; git commit -m 'merge repos'", dest))
}
combined_push <- function(dest, name) {
url_prefix <- "[email protected]:Reproducible-Science-Curriculum/"
url <- paste0(url_prefix, name)
system(sprintf("cd %s; git remote add origin %s", dest, url))
system(sprintf("cd %s; git push -f -u origin master", dest))
system(sprintf("cd %s/www; git remote add origin %s", dest, url))
system(sprintf("cd %s/www; git push -f -u origin gh-pages", dest))
}
## Explorations for creating github repo:
## ## Install cscheid/rgithub
## ## devtools::install_github("cscheid/rgithub")
## ## Follow instructions.
## library(github)
## library(httpuv)
## id <- "d1274f47e4c33dccb9f3"
## secret <- "0f82b55b52eea4cb589b4fbcedc6d96c6d8b440f"
## name <- "Reproducible-Science-Curriculum/rr-logistics-combined"
## ctx <- interactive.login(id, secret)
## me <- get.myself(ctx)
## github:::create.repository(name=name, ctx=ctx)
## .api.post.request(ctx, c("gists"), body = content)