2015-09-04 16:48:30 +02:00
|
|
|
#!/usr/bin/env ruby
|
2015-09-04 17:52:06 +02:00
|
|
|
# Generate GitHub Issues for tasks and deliverables
|
|
|
|
# - Each work package gets a WPX/README.md file
|
2015-09-04 16:48:30 +02:00
|
|
|
# - Each task gets an Issue
|
|
|
|
# - Each deliverable gets a Milestone
|
|
|
|
# - Each deliverable gets an Issue associated with its Milestone
|
2015-09-04 17:52:06 +02:00
|
|
|
# - Each deliverable Issue gets 'deliverable', 'WPX' tags
|
|
|
|
# - Each task Issue gets 'task', 'WPX' tags
|
2015-09-04 16:48:30 +02:00
|
|
|
|
2015-09-04 17:52:06 +02:00
|
|
|
# Run me from the proposal dir containing proposal.pdata:
|
|
|
|
# cd ~/OpenDreamKit/Proposal
|
|
|
|
# ~/path/to/LaTeX-Proposal/bin/generate-issues
|
2015-09-04 16:48:30 +02:00
|
|
|
|
|
|
|
require 'date'
|
|
|
|
require 'Octokit'
|
|
|
|
require 'netrc'
|
|
|
|
|
2015-09-04 17:52:06 +02:00
|
|
|
# constants for running the script are for OpenDreamKit
|
|
|
|
# update these for your own proposal
|
2015-09-04 16:48:30 +02:00
|
|
|
|
2015-09-04 17:52:06 +02:00
|
|
|
START_DATE = Date::new(2015, 9, 1) # start date of the project
|
|
|
|
HOMEPAGE = "http://opendreamkit.org"
|
2015-09-07 14:29:07 +02:00
|
|
|
PROPOSAL_URL = "https://github.com/OpenDreamKit/OpenDreamKit/raw/master/Proposal/proposal-www.pdf"
|
2015-09-04 17:52:06 +02:00
|
|
|
PROJECT = "OpenDreamKit"
|
2015-09-08 21:59:44 +02:00
|
|
|
REPO = "OpenDreamKit/OpenDreamKit"
|
|
|
|
TARGET = "final" # or 'proposal'
|
2015-09-04 16:48:30 +02:00
|
|
|
|
|
|
|
# throttle github creation requests to 5 Hz to avoid getting flagged for abuse
|
|
|
|
THROTTLE_SECONDS = 5
|
|
|
|
|
|
|
|
NATURES = {
|
|
|
|
'R' => 'Report',
|
|
|
|
'DEM' => 'Demonstrator',
|
2015-09-07 14:29:07 +02:00
|
|
|
'DEC' => 'Websites, Media, etc.',
|
2015-09-04 16:48:30 +02:00
|
|
|
'OTHER' => 'Other',
|
|
|
|
}
|
|
|
|
|
|
|
|
DISSEMINATIONS = {
|
|
|
|
'PU' => 'Public',
|
|
|
|
'CO' => 'Confidential',
|
|
|
|
'CI' => 'Classified',
|
|
|
|
}
|
|
|
|
|
|
|
|
SITES = {
|
|
|
|
'PS' => 'Université Paris-Sud',
|
|
|
|
'LL' => 'Logilab',
|
|
|
|
'UV' => 'Université de Versailles Saint-Quentin',
|
|
|
|
'UJF' => 'Université Joseph Fourier',
|
|
|
|
'UB' => 'CNRS',
|
|
|
|
'UO' => 'University of Oxford',
|
|
|
|
'USH' => 'University of Sheffield',
|
|
|
|
'USO' => 'University of Southampton',
|
|
|
|
'SA' => 'University of St Andrews',
|
|
|
|
'UW' => 'University of Warwick',
|
|
|
|
'JU' => 'Jacobs University Bremen',
|
|
|
|
'UK' => 'University of Kaiserslautern',
|
|
|
|
'US' => 'University of Silesia',
|
|
|
|
'ZH' => 'Universität Zürich',
|
|
|
|
'SR' => 'Simula Research Laboratory',
|
|
|
|
}
|
|
|
|
|
2015-09-04 18:37:32 +02:00
|
|
|
REVERSE_SITES = {}
|
|
|
|
SITES.each_pair do |key, name|
|
|
|
|
REVERSE_SITES[name] = key
|
|
|
|
end
|
|
|
|
|
2015-09-08 15:36:29 +02:00
|
|
|
# Some sites would prefer alternative abbreviations
|
|
|
|
REVERSE_SITES['University of St Andrews'] = 'USTAN'
|
|
|
|
REVERSE_SITES['Université de Versailles Saint-Quentin'] = 'UVSQ'
|
|
|
|
|
2015-09-04 17:52:06 +02:00
|
|
|
#------------------- Parsing proposal.pdata ---------------------
|
|
|
|
|
2015-09-04 16:48:30 +02:00
|
|
|
def split_line(line)
|
|
|
|
# super primitive state-machine line split (not going to regex this)
|
|
|
|
parts = []
|
|
|
|
level = 0
|
|
|
|
buffer = []
|
|
|
|
line.each_char do |c|
|
|
|
|
case c
|
|
|
|
when '{'
|
|
|
|
if level > 0
|
|
|
|
buffer.push c
|
|
|
|
end
|
|
|
|
level += 1
|
|
|
|
when '}'
|
|
|
|
level -= 1
|
|
|
|
if level > 0
|
|
|
|
buffer.push c
|
|
|
|
end
|
|
|
|
if level == 0
|
|
|
|
parts.push(scrub_tex(buffer.join('')))
|
|
|
|
buffer = []
|
|
|
|
end
|
|
|
|
else
|
|
|
|
if level > 0
|
|
|
|
buffer.push c
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return parts
|
|
|
|
end
|
|
|
|
|
2015-09-04 17:52:06 +02:00
|
|
|
|
2015-09-04 16:48:30 +02:00
|
|
|
def scrub_tex(text)
|
|
|
|
# scrub some latex markup from text
|
|
|
|
text.gsub!(/\\\w+/, '')
|
|
|
|
text.gsub!(/[{}]/, '')
|
|
|
|
text.strip.split.join(' ')
|
|
|
|
end
|
|
|
|
|
2015-09-04 17:52:06 +02:00
|
|
|
|
2015-09-04 16:48:30 +02:00
|
|
|
def transform_value(key, value)
|
|
|
|
case key
|
|
|
|
when 'lead'
|
|
|
|
return SITES[value]
|
|
|
|
when 'partners'
|
|
|
|
return value.split(',').map { |v| SITES[v] }
|
|
|
|
when 'dissem'
|
|
|
|
return DISSEMINATIONS[value]
|
|
|
|
when 'nature'
|
|
|
|
return NATURES[value]
|
|
|
|
when 'month'
|
|
|
|
return value.to_i
|
|
|
|
when 'delivs'
|
|
|
|
return value.split(',')
|
|
|
|
else
|
|
|
|
return scrub_tex(value)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2015-09-04 17:52:06 +02:00
|
|
|
def load_pdata(proposal_dir)
|
2015-09-08 15:37:12 +02:00
|
|
|
pdata = File.join(proposal_dir, "#{TARGET}.pdata")
|
|
|
|
deliv_data = File.join(proposal_dir, "#{TARGET}.deliverables")
|
2015-09-04 17:52:06 +02:00
|
|
|
|
|
|
|
workpackages = {} # mapping of workpackage id => wp info
|
2015-09-08 15:37:24 +02:00
|
|
|
deliverables = {}
|
2015-09-04 17:52:06 +02:00
|
|
|
|
|
|
|
File.readlines(pdata).each do |line|
|
|
|
|
key, *args = split_line line
|
|
|
|
|
|
|
|
case key
|
|
|
|
when 'wp'
|
|
|
|
name, key, value = args
|
|
|
|
value = transform_value(key, value)
|
|
|
|
if not workpackages.include? name
|
|
|
|
workpackages[name] = {
|
|
|
|
"tasks" => {},
|
|
|
|
"unknown-task" => nil,
|
|
|
|
"deliverables" => [],
|
|
|
|
}
|
|
|
|
end
|
|
|
|
wp = workpackages[name]
|
|
|
|
wp[key] = value
|
|
|
|
|
|
|
|
when 'task'
|
|
|
|
name, key, value = args
|
|
|
|
value = transform_value(key, value)
|
|
|
|
# find my workpackage
|
|
|
|
if name.index('@')
|
|
|
|
wpkey, short_name = name.split('@')
|
|
|
|
if short_name.match(/task\d+/)
|
|
|
|
workpackages[wpkey]['unknown-task'] = short_name
|
|
|
|
name = short_name
|
|
|
|
end
|
|
|
|
else
|
|
|
|
wpkey = workpackages.keys.select { |wpkey| name.start_with? wpkey }.first
|
|
|
|
end
|
|
|
|
# handle workpackage@taskNN weirdness
|
|
|
|
wp = workpackages[wpkey]
|
|
|
|
tasks = wp['tasks']
|
|
|
|
if not wp['unknown-task'].nil? and wp['unknown-task'] != name
|
|
|
|
tasks[name] = tasks.delete(wp['unknown-task'])
|
|
|
|
wp['unknown-task'] = nil
|
|
|
|
end
|
|
|
|
if not tasks.include? name
|
|
|
|
tasks[name] = {}
|
|
|
|
end
|
|
|
|
tasks[name][key] = value
|
2015-09-08 15:37:24 +02:00
|
|
|
when 'deliv'
|
|
|
|
name, key, value = args
|
|
|
|
|
|
|
|
value = transform_value(key, value)
|
|
|
|
if not deliverables.include? name
|
|
|
|
deliverables[name] = {}
|
|
|
|
end
|
|
|
|
deliverables[name][key] = value
|
2015-09-04 17:52:06 +02:00
|
|
|
|
|
|
|
else
|
|
|
|
# DEBUG:
|
|
|
|
# puts " Ignored: #{args}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-09-08 15:37:24 +02:00
|
|
|
# get deliverable data, workpackage id from proposal.deliverables
|
2015-09-04 17:52:06 +02:00
|
|
|
File.readlines(deliv_data).each do |line|
|
|
|
|
args = split_line line
|
2015-09-08 15:37:24 +02:00
|
|
|
name = args[3]
|
|
|
|
if deliverables.include? name
|
|
|
|
deliverable = deliverables[name]
|
|
|
|
else
|
|
|
|
deliverable = {}
|
|
|
|
end
|
2015-09-04 17:52:06 +02:00
|
|
|
month = args[0].to_i
|
2015-09-08 15:37:24 +02:00
|
|
|
deliverable = (deliverables[name] or {}).merge({
|
2015-09-04 17:52:06 +02:00
|
|
|
"month" => month,
|
|
|
|
# due date is last day of the given month, so subtract one day
|
|
|
|
"due_date" => (START_DATE >> month) - 1,
|
|
|
|
"label" => scrub_tex(args[2]),
|
|
|
|
"deliv_id" => args[3],
|
|
|
|
"dissem" => transform_value('dissem', args[4]),
|
|
|
|
"nature" => transform_value('nature', args[5]),
|
|
|
|
"title" => scrub_tex(args[6]),
|
|
|
|
"lead" => SITES[scrub_tex(args[8])],
|
2015-09-08 15:37:24 +02:00
|
|
|
})
|
|
|
|
wpid = scrub_tex(args[7])
|
2015-09-04 17:52:06 +02:00
|
|
|
wp = workpackages.values.find {|wp| wp['label'] == wpid}
|
|
|
|
wp['deliverables'].push(deliverable)
|
2015-09-08 15:37:24 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
workpackages.values.each do |wp|
|
2015-09-04 17:52:06 +02:00
|
|
|
wp['deliverables'].sort_by! {|d| d['label']}
|
|
|
|
end
|
|
|
|
|
|
|
|
return workpackages.values.sort_by {|wp| wp['label']}
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
#--------------- GitHub-related ---------------------
|
|
|
|
|
2015-09-04 16:48:30 +02:00
|
|
|
def check_token
|
|
|
|
# get GitHub auth token, creating one if we don't find it.
|
|
|
|
rc = Netrc.read Netrc.default_path
|
|
|
|
if not rc['api.github.com'].nil?
|
|
|
|
return
|
|
|
|
end
|
|
|
|
puts "We need your password to generate an OAuth token. The password will not be stored."
|
|
|
|
username = ask "Username: "
|
|
|
|
password = ask("Password: ") { |q| q.echo = '*' }
|
|
|
|
client = Octokit::Client.new(
|
|
|
|
:login => username,
|
|
|
|
:password => password,
|
|
|
|
)
|
|
|
|
reply = client.create_authorization(
|
|
|
|
:scopes => ["public_repo"],
|
|
|
|
:note => "Issue Migration",
|
|
|
|
)
|
|
|
|
token = reply.token
|
|
|
|
rc['api.github.com'] = username, token
|
|
|
|
rc.save
|
|
|
|
end
|
|
|
|
|
2015-09-04 17:52:06 +02:00
|
|
|
$cache = {
|
|
|
|
'issues' => {},
|
|
|
|
'milestones' => {},
|
|
|
|
}
|
|
|
|
|
|
|
|
def get_issues(github, repo)
|
|
|
|
# get issues for a repo (cached)
|
|
|
|
cache = $cache['issues']
|
|
|
|
if not cache.include? repo
|
|
|
|
cache[repo] = github.issues(repo)
|
|
|
|
end
|
|
|
|
return cache[repo]
|
|
|
|
end
|
|
|
|
|
|
|
|
def get_milestones(github, repo)
|
|
|
|
# get issues for a repo (cached)
|
|
|
|
cache = $cache['milestones']
|
|
|
|
if not cache.include? repo
|
|
|
|
cache[repo] = github.list_milestones(repo)
|
|
|
|
end
|
|
|
|
return cache[repo]
|
|
|
|
end
|
|
|
|
|
|
|
|
# Templates for making readmes, issues
|
2015-09-04 16:48:30 +02:00
|
|
|
|
2015-09-04 17:52:06 +02:00
|
|
|
README_TPL = <<-END
|
2015-09-04 16:48:30 +02:00
|
|
|
# %{title}
|
|
|
|
|
2015-09-07 14:29:07 +02:00
|
|
|
Lead Institution: %{lead}
|
2015-09-04 16:48:30 +02:00
|
|
|
|
2015-09-04 17:52:06 +02:00
|
|
|
See page %{page} of the [proposal](#{PROPOSAL_URL}) for the full description.
|
2015-09-04 16:48:30 +02:00
|
|
|
END
|
|
|
|
|
2015-09-04 17:52:06 +02:00
|
|
|
TASK_TPL = <<-END
|
2015-09-07 14:29:07 +02:00
|
|
|
- **%{wplabel}:** [%{wptitle}](https://github.com/#{REPO}/tree/master/%{wplabel})
|
|
|
|
- **Lead Institution:** %{lead}
|
|
|
|
- **Partners:** %{partners}
|
|
|
|
- **Work phases:** %{wphases}
|
2015-09-04 16:48:30 +02:00
|
|
|
|
2015-09-07 14:29:07 +02:00
|
|
|
See page %{page} of the [proposal](#{PROPOSAL_URL}) for the full description.
|
2015-09-04 16:48:30 +02:00
|
|
|
END
|
|
|
|
|
2015-09-04 17:52:06 +02:00
|
|
|
DELIV_TPL = <<-END
|
2015-09-07 14:29:07 +02:00
|
|
|
- **%{wplabel}:** [%{wptitle}](https://github.com/#{REPO}/tree/master/%{wplabel})
|
|
|
|
- **Lead Institution:** %{lead}
|
|
|
|
- **Due:** %{date} (month %{month})
|
|
|
|
- **Nature:** %{nature}
|
2015-09-08 15:37:24 +02:00
|
|
|
|
|
|
|
See page %{page} of the [proposal](#{PROPOSAL_URL}) for the full description.
|
2015-09-04 16:48:30 +02:00
|
|
|
END
|
|
|
|
|
2015-09-04 17:52:06 +02:00
|
|
|
DELIV_MILESTONE_TPL = "# %{title}\n\n#{DELIV_TPL}"
|
|
|
|
|
2015-09-04 16:48:30 +02:00
|
|
|
|
2015-09-04 18:42:53 +02:00
|
|
|
def make_task_issue(github, repo, task, workpackage, options)
|
2015-09-04 16:48:30 +02:00
|
|
|
title = "#{task['label']}: #{task['title']}"
|
|
|
|
issues = get_issues(github, repo)
|
|
|
|
issue = issues.find { |i| i.title.start_with?(task['label'] + ':') }
|
|
|
|
if issue.nil?
|
2015-09-04 17:52:06 +02:00
|
|
|
body = TASK_TPL % {
|
2015-09-07 14:29:07 +02:00
|
|
|
wplabel: workpackage['label'],
|
|
|
|
wptitle: workpackage['title'],
|
2015-09-04 16:48:30 +02:00
|
|
|
lead: task['lead'],
|
2015-09-07 14:29:07 +02:00
|
|
|
page: task['page'],
|
2015-09-04 16:48:30 +02:00
|
|
|
wphases: task['wphases'],
|
2015-09-04 18:08:36 +02:00
|
|
|
partners: (task['partners'] or ['None']).join(', ')
|
2015-09-04 16:48:30 +02:00
|
|
|
}
|
|
|
|
puts "\n\nMaking Issue on #{repo}: #{title}"
|
|
|
|
puts body
|
|
|
|
|
2015-09-04 17:17:10 +02:00
|
|
|
github.create_issue(repo, title, body, options)
|
2015-09-04 16:48:30 +02:00
|
|
|
# throttle creation calls to avoid flags for abuse
|
|
|
|
sleep THROTTLE_SECONDS
|
|
|
|
else
|
|
|
|
puts "Found Issue #{repo}##{issue.number}: #{issue.title}"
|
2015-09-04 17:32:20 +02:00
|
|
|
existing_labels = issue.labels.map { |label| label['name']}
|
|
|
|
missing_labels = options[:labels].reject { |label| existing_labels.include? label }
|
|
|
|
if not missing_labels.empty?
|
|
|
|
puts "Updating milestone, labels on #{repo}##{issue.number}"
|
|
|
|
github.update_issue(repo, issue.number, options)
|
|
|
|
sleep THROTTLE_SECONDS
|
|
|
|
end
|
2015-09-04 16:48:30 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-09-04 17:52:06 +02:00
|
|
|
|
2015-09-04 18:42:53 +02:00
|
|
|
def make_deliverable_issue(github, repo, deliverable, workpackage, options)
|
2015-09-04 16:48:30 +02:00
|
|
|
title = "#{deliverable['label']}: #{deliverable['title']}"
|
|
|
|
issues = get_issues(github, repo)
|
|
|
|
issue = issues.find { |i| i.title.start_with?(deliverable['label'] + ':') }
|
|
|
|
if issue.nil?
|
2015-09-04 17:52:06 +02:00
|
|
|
body = DELIV_TPL % {
|
2015-09-07 14:29:07 +02:00
|
|
|
wplabel: workpackage['label'],
|
|
|
|
wptitle: workpackage['title'],
|
2015-09-04 16:48:30 +02:00
|
|
|
lead: deliverable['lead'],
|
|
|
|
date: deliverable['due_date'],
|
|
|
|
month: deliverable['month'],
|
|
|
|
nature: deliverable['nature'],
|
2015-09-08 15:37:24 +02:00
|
|
|
page: deliverable['page'],
|
2015-09-04 16:48:30 +02:00
|
|
|
}
|
|
|
|
puts "\n\nMaking Issue on #{repo}: #{title}"
|
|
|
|
puts body
|
2015-09-04 17:17:10 +02:00
|
|
|
github.create_issue(repo, title, body, options)
|
2015-09-04 16:48:30 +02:00
|
|
|
# throttle creation calls to avoid flags for abuse
|
|
|
|
sleep THROTTLE_SECONDS
|
|
|
|
else
|
|
|
|
puts "Found Issue #{repo}##{issue.number}: #{issue.title}"
|
2015-09-04 17:32:20 +02:00
|
|
|
existing_labels = issue.labels.map { |label| label['name']}
|
|
|
|
missing_labels = options[:labels].reject { |label| existing_labels.include? label }
|
|
|
|
if issue.milestone.nil? or not missing_labels.empty?
|
|
|
|
puts "Updating milestone, labels on #{repo}##{issue.number}"
|
|
|
|
github.update_issue(repo, issue.number, options)
|
|
|
|
sleep THROTTLE_SECONDS
|
|
|
|
end
|
2015-09-04 16:48:30 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-09-04 17:52:06 +02:00
|
|
|
|
2015-09-04 18:42:53 +02:00
|
|
|
def make_deliverable_milestone(github, repo, deliverable, workpackage)
|
2015-09-04 16:48:30 +02:00
|
|
|
title = deliverable['label']
|
|
|
|
|
|
|
|
milestone = get_milestones(github, repo).find { |ms| ms.title == title }
|
|
|
|
if milestone.nil?
|
|
|
|
puts "Making milestone on #{repo}: #{title}"
|
2015-09-04 17:52:06 +02:00
|
|
|
body = DELIV_MILESTONE_TPL % {
|
2015-09-07 14:29:07 +02:00
|
|
|
wplabel: workpackage['label'],
|
|
|
|
wptitle: workpackage['title'],
|
2015-09-04 16:48:30 +02:00
|
|
|
title: deliverable['title'],
|
|
|
|
lead: deliverable['lead'],
|
|
|
|
date: deliverable['due_date'],
|
|
|
|
month: deliverable['month'],
|
|
|
|
nature: deliverable['nature'],
|
2015-09-08 15:37:24 +02:00
|
|
|
page: deliverable['page'],
|
2015-09-04 16:48:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
milestone = github.create_milestone(repo, title,
|
|
|
|
:due_on => deliverable['due_date'],
|
|
|
|
:description => body,
|
|
|
|
)
|
|
|
|
# throttle creation calls to avoid flags for abuse
|
|
|
|
sleep THROTTLE_SECONDS
|
|
|
|
else
|
|
|
|
puts "Milestone #{repo}@#{title} exists"
|
|
|
|
end
|
|
|
|
return milestone.number
|
|
|
|
end
|
|
|
|
|
2015-09-04 17:52:06 +02:00
|
|
|
|
2015-09-04 17:02:29 +02:00
|
|
|
def populate_workpackage(github, repo, workpackage)
|
|
|
|
# populate issues for a given workpackage
|
|
|
|
label = workpackage['label']
|
|
|
|
|
|
|
|
readme_path = "#{label}/README.md"
|
2015-09-04 16:48:30 +02:00
|
|
|
begin
|
2015-09-04 17:02:29 +02:00
|
|
|
github.contents(repo, :path => readme_path)
|
2015-09-04 16:48:30 +02:00
|
|
|
rescue Octokit::NotFound
|
2015-09-04 17:52:06 +02:00
|
|
|
readme = README_TPL % {
|
2015-09-04 16:48:30 +02:00
|
|
|
title: "#{workpackage['label']}: #{workpackage['title']}",
|
|
|
|
lead: workpackage['lead'],
|
|
|
|
page: workpackage['page'],
|
|
|
|
}
|
|
|
|
|
2015-09-04 17:02:29 +02:00
|
|
|
puts "Creating readme at #{repo}/#{readme_path}"
|
2015-09-04 16:48:30 +02:00
|
|
|
puts readme
|
2015-09-04 17:02:29 +02:00
|
|
|
github.create_contents(repo, readme_path, "Creating #{readme_path}", readme)
|
2015-09-04 16:48:30 +02:00
|
|
|
# throttle creation calls to avoid flags for abuse
|
|
|
|
sleep THROTTLE_SECONDS
|
|
|
|
end
|
|
|
|
|
|
|
|
workpackage['tasks'].each_value do |task|
|
2015-09-04 18:37:32 +02:00
|
|
|
org_labels = [REVERSE_SITES[task['lead']]] + \
|
|
|
|
(task['partners'] or []).map {|site| REVERSE_SITES[site]}
|
|
|
|
|
2015-09-04 18:42:53 +02:00
|
|
|
make_task_issue(github, repo, task, workpackage,
|
2015-09-04 17:17:10 +02:00
|
|
|
:labels => [
|
|
|
|
'task',
|
|
|
|
workpackage['label'],
|
2015-09-04 18:37:32 +02:00
|
|
|
] + org_labels
|
2015-09-04 18:42:53 +02:00
|
|
|
)
|
2015-09-04 16:48:30 +02:00
|
|
|
end
|
|
|
|
workpackage['deliverables'].each do |deliverable|
|
2015-09-04 18:42:53 +02:00
|
|
|
milestone = make_deliverable_milestone(github, repo, deliverable, workpackage)
|
|
|
|
make_deliverable_issue(github, repo, deliverable, workpackage, {
|
2015-09-04 17:17:10 +02:00
|
|
|
:milestone => milestone,
|
|
|
|
:labels => [
|
|
|
|
'deliverable',
|
|
|
|
workpackage['label'],
|
2015-09-04 18:37:32 +02:00
|
|
|
REVERSE_SITES[deliverable['lead']]
|
2015-09-04 17:32:20 +02:00
|
|
|
]
|
2015-09-04 17:17:10 +02:00
|
|
|
})
|
2015-09-04 16:48:30 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2015-09-04 17:52:06 +02:00
|
|
|
def main(proposal_dir)
|
|
|
|
# run the whole thing
|
2015-09-04 16:48:30 +02:00
|
|
|
|
2015-09-04 17:52:06 +02:00
|
|
|
# verify that there's a GitHub token in .netrc
|
|
|
|
check_token
|
2015-09-04 16:48:30 +02:00
|
|
|
|
2015-09-04 17:52:06 +02:00
|
|
|
# create client
|
|
|
|
github = Octokit::Client.new(:netrc => true)
|
|
|
|
github.auto_paginate = true
|
2015-09-04 16:48:30 +02:00
|
|
|
|
2015-09-04 17:52:06 +02:00
|
|
|
load_pdata(proposal_dir).each do |wp|
|
|
|
|
populate_workpackage(github, REPO, wp)
|
2015-09-04 16:48:30 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-09-04 17:52:06 +02:00
|
|
|
if __FILE__ == $0
|
|
|
|
puts ARGV
|
|
|
|
if ARGV.length > 1
|
|
|
|
proposal_dir = ARGV[1]
|
|
|
|
else
|
|
|
|
proposal_dir = '.'
|
|
|
|
end
|
|
|
|
main(proposal_dir)
|
|
|
|
end
|