Merge pull request #11 from minrk/generate-issues
add site labels to issues
This commit is contained in:
commit
ee8fc5ca5f
@ -58,6 +58,11 @@ SITES = {
|
|||||||
'SR' => 'Simula Research Laboratory',
|
'SR' => 'Simula Research Laboratory',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
REVERSE_SITES = {}
|
||||||
|
SITES.each_pair do |key, name|
|
||||||
|
REVERSE_SITES[name] = key
|
||||||
|
end
|
||||||
|
|
||||||
#------------------- Parsing proposal.pdata ---------------------
|
#------------------- Parsing proposal.pdata ---------------------
|
||||||
|
|
||||||
def split_line(line)
|
def split_line(line)
|
||||||
@ -257,6 +262,8 @@ See page %{page} of the [proposal](#{PROPOSAL_URL}) for the full description.
|
|||||||
END
|
END
|
||||||
|
|
||||||
TASK_TPL = <<-END
|
TASK_TPL = <<-END
|
||||||
|
Work Package %{wptitle}
|
||||||
|
|
||||||
Lead Institution: %{lead}
|
Lead Institution: %{lead}
|
||||||
|
|
||||||
Partners: %{partners}
|
Partners: %{partners}
|
||||||
@ -265,6 +272,8 @@ Work phases: %{wphases}
|
|||||||
END
|
END
|
||||||
|
|
||||||
DELIV_TPL = <<-END
|
DELIV_TPL = <<-END
|
||||||
|
Work Package %{wptitle}
|
||||||
|
|
||||||
Lead Institution: %{lead}
|
Lead Institution: %{lead}
|
||||||
|
|
||||||
Due: %{date} (month %{month})
|
Due: %{date} (month %{month})
|
||||||
@ -275,12 +284,13 @@ END
|
|||||||
DELIV_MILESTONE_TPL = "# %{title}\n\n#{DELIV_TPL}"
|
DELIV_MILESTONE_TPL = "# %{title}\n\n#{DELIV_TPL}"
|
||||||
|
|
||||||
|
|
||||||
def make_task_issue(github, repo, task, options)
|
def make_task_issue(github, repo, task, workpackage, options)
|
||||||
title = "#{task['label']}: #{task['title']}"
|
title = "#{task['label']}: #{task['title']}"
|
||||||
issues = get_issues(github, repo)
|
issues = get_issues(github, repo)
|
||||||
issue = issues.find { |i| i.title.start_with?(task['label'] + ':') }
|
issue = issues.find { |i| i.title.start_with?(task['label'] + ':') }
|
||||||
if issue.nil?
|
if issue.nil?
|
||||||
body = TASK_TPL % {
|
body = TASK_TPL % {
|
||||||
|
wptitle: "#{workpackage['label']}: #{workpackage['title']}",
|
||||||
lead: task['lead'],
|
lead: task['lead'],
|
||||||
wphases: task['wphases'],
|
wphases: task['wphases'],
|
||||||
partners: (task['partners'] or ['None']).join(', ')
|
partners: (task['partners'] or ['None']).join(', ')
|
||||||
@ -304,12 +314,13 @@ def make_task_issue(github, repo, task, options)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def make_deliverable_issue(github, repo, deliverable, options)
|
def make_deliverable_issue(github, repo, deliverable, workpackage, options)
|
||||||
title = "#{deliverable['label']}: #{deliverable['title']}"
|
title = "#{deliverable['label']}: #{deliverable['title']}"
|
||||||
issues = get_issues(github, repo)
|
issues = get_issues(github, repo)
|
||||||
issue = issues.find { |i| i.title.start_with?(deliverable['label'] + ':') }
|
issue = issues.find { |i| i.title.start_with?(deliverable['label'] + ':') }
|
||||||
if issue.nil?
|
if issue.nil?
|
||||||
body = DELIV_TPL % {
|
body = DELIV_TPL % {
|
||||||
|
wptitle: "#{workpackage['label']}: #{workpackage['title']}",
|
||||||
lead: deliverable['lead'],
|
lead: deliverable['lead'],
|
||||||
date: deliverable['due_date'],
|
date: deliverable['due_date'],
|
||||||
month: deliverable['month'],
|
month: deliverable['month'],
|
||||||
@ -333,13 +344,14 @@ def make_deliverable_issue(github, repo, deliverable, options)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def make_deliverable_milestone(github, repo, deliverable)
|
def make_deliverable_milestone(github, repo, deliverable, workpackage)
|
||||||
title = deliverable['label']
|
title = deliverable['label']
|
||||||
|
|
||||||
milestone = get_milestones(github, repo).find { |ms| ms.title == title }
|
milestone = get_milestones(github, repo).find { |ms| ms.title == title }
|
||||||
if milestone.nil?
|
if milestone.nil?
|
||||||
puts "Making milestone on #{repo}: #{title}"
|
puts "Making milestone on #{repo}: #{title}"
|
||||||
body = DELIV_MILESTONE_TPL % {
|
body = DELIV_MILESTONE_TPL % {
|
||||||
|
wptitle: "#{workpackage['label']}: #{workpackage['title']}",
|
||||||
title: deliverable['title'],
|
title: deliverable['title'],
|
||||||
lead: deliverable['lead'],
|
lead: deliverable['lead'],
|
||||||
date: deliverable['due_date'],
|
date: deliverable['due_date'],
|
||||||
@ -382,20 +394,24 @@ def populate_workpackage(github, repo, workpackage)
|
|||||||
end
|
end
|
||||||
|
|
||||||
workpackage['tasks'].each_value do |task|
|
workpackage['tasks'].each_value do |task|
|
||||||
make_task_issue(github, repo, task, {
|
org_labels = [REVERSE_SITES[task['lead']]] + \
|
||||||
|
(task['partners'] or []).map {|site| REVERSE_SITES[site]}
|
||||||
|
|
||||||
|
make_task_issue(github, repo, task, workpackage,
|
||||||
:labels => [
|
:labels => [
|
||||||
'task',
|
'task',
|
||||||
workpackage['label'],
|
workpackage['label'],
|
||||||
]
|
] + org_labels
|
||||||
})
|
)
|
||||||
end
|
end
|
||||||
workpackage['deliverables'].each do |deliverable|
|
workpackage['deliverables'].each do |deliverable|
|
||||||
milestone = make_deliverable_milestone(github, repo, deliverable)
|
milestone = make_deliverable_milestone(github, repo, deliverable, workpackage)
|
||||||
make_deliverable_issue(github, repo, deliverable, {
|
make_deliverable_issue(github, repo, deliverable, workpackage, {
|
||||||
:milestone => milestone,
|
:milestone => milestone,
|
||||||
:labels => [
|
:labels => [
|
||||||
'deliverable',
|
'deliverable',
|
||||||
workpackage['label'],
|
workpackage['label'],
|
||||||
|
REVERSE_SITES[deliverable['lead']]
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user