-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclone-ddf-repos.groovy
executable file
·40 lines (35 loc) · 1.14 KB
/
clone-ddf-repos.groovy
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
@Grapes([
@Grab(group='joda-time', module='joda-time', version='2.1'),
@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.7' )])
import groovyx.net.http.*
import static groovyx.net.http.ContentType.*
import static groovyx.net.http.Method.*
import org.joda.time.*
import org.joda.time.format.*
DateTimeFormatter inputfmt = ISODateTimeFormat.dateTimeNoMillis().withZone(DateTimeZone.UTC)
def http = new HTTPBuilder( 'https://api.github.com/' )
def header_accept = 'application/json'
def codice_repos = ''
http.request(GET,JSON) { req ->
uri.path = 'orgs/codice/repos'
uri.query = [type: 'source']
headers.'Accept' = header_accept
// Requires a user-agent
headers.'User-Agent' = 'Mozilla/5.0 Ubuntu/8.10 Firefox/3.0.4'
response.success = { resp, json ->
assert resp.status == 200
repoList = json
}
}
println "Found ${repoList.size} Codice repos."
def ddfRepos = 0
repoList.each {
def repoName = it.name
def url = it.clone_url
if (repoName.startsWith('ddf')) {
println "Cloning repo: ${repoName} at ${url}"
"git clone ${url}".execute()
ddfRepos++
}
}
println "Cloned ${ddfRepos} DDF repos."