Skip to content

Instantly share code, notes, and snippets.

@mojavelinux
Created May 15, 2012 08:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mojavelinux/2699890 to your computer and use it in GitHub Desktop.
Save mojavelinux/2699890 to your computer and use it in GitHub Desktop.
JBoss Community project leads from JIRA
/**
* This script curates a list all the project leads of JBoss Community projects using the
* issue tracker as the information authority.
*/
// The default TTL in Ivy 2.1.0 is 10 seconds, which results in frequent slow executions. You can get
// faster startup by changing it to a much larger interval.
// Creating the file ~/.groovy/grapeConfig.xml from
// http://svn.codehaus.org/groovy/tags/GROOVY_1_7_10/src/main/groovy/grape/defaultGrapeConfig.xml
// and customize the ttl default property.
//
// <ivysettings>
// <property name="ivy.cache.ttl.default" value="1440m"/>
// ...
// </ivysettings>
@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.5.2')
import groovyx.net.http.RESTClient
import groovy.xml.MarkupBuilder
@Grab(group='commons-lang', module='commons-lang', version='2.4')
import org.apache.commons.lang.StringEscapeUtils
class Lead {
String username
String name
String lastName
String instance
String toString() {
"${name} (${username})"
}
}
class Project {
String key
String name
Lead lead
String toString() {
"${name} (${key}) led by ${lead.name}"
}
}
String JBOSS_REST_API_ROOT = 'http://issues.jboss.org/rest/api/latest/'
String JBOSS_GADGET_REST_API_ROOT = 'https://issues.jboss.org/rest/gadget/1.0/'
def jbossExcludeCats = [10101, 10102, 10010, 10030, 10091]
String HIBERNATE_REST_API_ROOT = 'http://hibernate.onjira.com/rest/api/latest/'
String HIBERNATE_GADGET_REST_API_ROOT = 'http://hibernate.onjira.com/rest/gadget/1.0/'
def hibernateActiveCat = 10030
def cli = new CliBuilder(usage: "projectleads")
// Pull from JBoss Issue Tracker
def jbossRest = new RESTClient(JBOSS_REST_API_ROOT)
def res = jbossRest.get(
path: 'project')
def keys = []
res.data.each {
if (!(it.key.startsWith('SEAM') && it.key != 'SEAM') &&
!(it.key.startsWith('WELD') && it.key != 'WELD') &&
it.key != 'JBTP' && it.key != 'EJBBOOK' && !it.name.contains('Planning')) {
//println "${it.key} - ${it.name}"
keys.add(it.key)
}
}
res = new RESTClient(JBOSS_GADGET_REST_API_ROOT).get(
path: 'project/generate',
query: [projectsOrCategories: jbossExcludeCats.collect { "cat${it}" }.join('|')]
)
res.data.categories.each { c ->
c.projects.each { p ->
keys.remove(p.key)
}
}
def leads = [:]
keys.each {
res = jbossRest.get(
path : "project/${it}")
def data = res.data
def l = new Lead(username: data.lead.name, name: data.lead.displayName, lastName: data.lead.displayName.substring(data.lead.displayName.indexOf(' ') + 1), instance: 'jboss')
if (l.lastName.startsWith('de ')) {
l.lastName = l.lastName.substring(3)
}
else if (l.lastName.startsWith('Rydahl ')) {
l.lastName = l.lastName.substring(7)
}
def p = new Project(key: data.key, name: data.name, lead: l)
if (p.name.startsWith('Seam 3')) {
p.name = 'Seam 3'
}
if (!leads.containsKey(l.username)) {
leads[l.username] = [lead: l, projects: [p]]
}
else {
leads[l.username].projects.add(p)
}
}
//leads.values().sort { a, b -> a.lead.lastName.toLowerCase() <=> b.lead.lastName.toLowerCase() }.each {
// def projects = it.projects.collect { it.name }
// println "${it.lead} leads ${projects}"
//}
// Pull from Hibernate Issue Tracker
keys = []
res = new RESTClient(HIBERNATE_GADGET_REST_API_ROOT).get(
path: 'project/generate',
query: [projectsOrCategories: "cat${hibernateActiveCat}"]
)
res.data.categories.each { c ->
c.projects.each { p ->
keys.add(p.key)
}
}
//leads = [:]
def hibernateRest = new RESTClient(HIBERNATE_REST_API_ROOT)
keys.each {
res = hibernateRest.get(
path : "project/${it}")
def data = res.data
def l = new Lead(username: data.lead.name, name: data.lead.displayName, lastName: data.lead.displayName.substring(data.lead.displayName.indexOf(' ') + 1), instance: 'hibernate')
if (l.lastName.startsWith('Rydahl ')) {
l.lastName = l.lastName.substring(7)
}
def p = new Project(key: data.key, name: data.name, lead: l)
if (!leads.containsKey(l.username)) {
leads[l.username] = [lead: l, projects: [p]]
}
else {
leads[l.username].projects.add(p)
}
}
leads.values().sort { a, b -> a.lead.lastName.toLowerCase() <=> b.lead.lastName.toLowerCase() }.each {
def projects = it.projects.collect { it.name }
println "${it.lead} leads ${projects}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment