move to single-repo model
READMEs go in folders
This commit is contained in:
parent
e3a90f648e
commit
3d8c47d408
@ -14,10 +14,10 @@ require 'netrc'
|
|||||||
proposal_dir = '.'
|
proposal_dir = '.'
|
||||||
|
|
||||||
$start_date = Date::new(2015, 9, 1) # start date of the project
|
$start_date = Date::new(2015, 9, 1) # start date of the project
|
||||||
$github_org = 'minrk-odktest'
|
|
||||||
$homepage = "http://opendreamkit.org"
|
$homepage = "http://opendreamkit.org"
|
||||||
$proposal_url = "https://github.com/OpenDreamKit/OpenDreamKit"
|
$proposal_url = "https://github.com/OpenDreamKit/OpenDreamKit"
|
||||||
$project = "OpenDreamKit"
|
$project = "OpenDreamKit"
|
||||||
|
$repo = "minrk/odktest"
|
||||||
|
|
||||||
# throttle github creation requests to 5 Hz to avoid getting flagged for abuse
|
# throttle github creation requests to 5 Hz to avoid getting flagged for abuse
|
||||||
THROTTLE_SECONDS = 5
|
THROTTLE_SECONDS = 5
|
||||||
@ -134,14 +134,11 @@ end
|
|||||||
|
|
||||||
|
|
||||||
$readme_tpl = <<-END
|
$readme_tpl = <<-END
|
||||||
|
|
||||||
# %{title}
|
# %{title}
|
||||||
|
|
||||||
This is a Work Package for [#{$project}](#{$homepage}).
|
|
||||||
|
|
||||||
Lead institution: %{lead}
|
Lead institution: %{lead}
|
||||||
|
|
||||||
Page in the [proposal](#{$proposal_url}) for the full description: %{page}
|
See page %{page} of the [proposal](#{$proposal_url}) for the full description.
|
||||||
END
|
END
|
||||||
|
|
||||||
$task_tpl = <<-END
|
$task_tpl = <<-END
|
||||||
@ -230,28 +227,13 @@ def make_deliverable_milestone(github, repo, deliverable)
|
|||||||
return milestone.number
|
return milestone.number
|
||||||
end
|
end
|
||||||
|
|
||||||
def make_repo(github, workpackage)
|
def populate_workpackage(github, repo, workpackage)
|
||||||
repo_name = workpackage['label']
|
# populate issues for a given workpackage
|
||||||
# repo_name = "WP" # single-repo
|
label = workpackage['label']
|
||||||
repo = "#{$github_org}/#{repo_name}"
|
|
||||||
# ensure the repo exists:
|
readme_path = "#{label}/README.md"
|
||||||
begin
|
begin
|
||||||
github.repository(repo)
|
github.contents(repo, :path => readme_path)
|
||||||
puts "Found repo: #{repo}"
|
|
||||||
rescue Octokit::NotFound
|
|
||||||
puts "Creating repo: #{repo}"
|
|
||||||
github.create_repository(repo_name,
|
|
||||||
:organization => $github_org,
|
|
||||||
:description => workpackage['title'],
|
|
||||||
:has_downloads => false,
|
|
||||||
:has_wiki => false,
|
|
||||||
)
|
|
||||||
# throttle creation to avoid flags for abuse
|
|
||||||
sleep THROTTLE_SECONDS
|
|
||||||
end
|
|
||||||
|
|
||||||
begin
|
|
||||||
github.readme(repo)
|
|
||||||
rescue Octokit::NotFound
|
rescue Octokit::NotFound
|
||||||
readme = $readme_tpl % {
|
readme = $readme_tpl % {
|
||||||
title: "#{workpackage['label']}: #{workpackage['title']}",
|
title: "#{workpackage['label']}: #{workpackage['title']}",
|
||||||
@ -259,9 +241,9 @@ def make_repo(github, workpackage)
|
|||||||
page: workpackage['page'],
|
page: workpackage['page'],
|
||||||
}
|
}
|
||||||
|
|
||||||
puts "Creating Readme on #{repo}"
|
puts "Creating readme at #{repo}/#{readme_path}"
|
||||||
puts readme
|
puts readme
|
||||||
github.create_contents(repo, 'README.md', 'Creating README', readme)
|
github.create_contents(repo, readme_path, "Creating #{readme_path}", readme)
|
||||||
# throttle creation calls to avoid flags for abuse
|
# throttle creation calls to avoid flags for abuse
|
||||||
sleep THROTTLE_SECONDS
|
sleep THROTTLE_SECONDS
|
||||||
end
|
end
|
||||||
@ -303,31 +285,11 @@ def load_pdata(proposal_dir)
|
|||||||
deliv_data = File.join(proposal_dir, 'proposal.deliverables')
|
deliv_data = File.join(proposal_dir, 'proposal.deliverables')
|
||||||
|
|
||||||
workpackages = {} # mapping of workpackage id => wp info
|
workpackages = {} # mapping of workpackage id => wp info
|
||||||
deliverables = {} # mapping of deliv id => deliv info
|
|
||||||
milestones = {} # mapping of milestone id => milestone info
|
|
||||||
|
|
||||||
File.readlines(pdata).each do |line|
|
File.readlines(pdata).each do |line|
|
||||||
key, *args = split_line line
|
key, *args = split_line line
|
||||||
|
|
||||||
case key
|
case key
|
||||||
when 'mile'
|
|
||||||
# milestones are unused
|
|
||||||
name, key, value = args
|
|
||||||
value = transform_value(key, value)
|
|
||||||
# puts " milestone: #{key} => #{value}"
|
|
||||||
if not milestones.include? name
|
|
||||||
milestones[name] = {}
|
|
||||||
end
|
|
||||||
milestones[name][key] = value
|
|
||||||
if key == 'delivs'
|
|
||||||
value.each do |deliv|
|
|
||||||
if not deliverables.include? deliv
|
|
||||||
deliverables[deliv] = {}
|
|
||||||
end
|
|
||||||
deliverables[deliv]['milestone'] = name
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
when 'wp'
|
when 'wp'
|
||||||
name, key, value = args
|
name, key, value = args
|
||||||
value = transform_value(key, value)
|
value = transform_value(key, value)
|
||||||
@ -366,28 +328,6 @@ def load_pdata(proposal_dir)
|
|||||||
end
|
end
|
||||||
tasks[name][key] = value
|
tasks[name][key] = value
|
||||||
|
|
||||||
when 'deliv'
|
|
||||||
# get deliverable data from proposal.deliverables
|
|
||||||
next
|
|
||||||
name, key, value = args
|
|
||||||
value = transform_value(key, value)
|
|
||||||
|
|
||||||
|
|
||||||
if not deliverables.include? name
|
|
||||||
deliverables[name] = {}
|
|
||||||
end
|
|
||||||
deliverables[name][key] = value
|
|
||||||
|
|
||||||
# find my workpackage
|
|
||||||
if name.index('@')
|
|
||||||
wpkey = name.split('@').first
|
|
||||||
else
|
|
||||||
wpkey = workpackages.keys.select { |wpkey| name.start_with? wpkey }.first
|
|
||||||
end
|
|
||||||
wp = workpackages[wpkey]
|
|
||||||
if not wp['deliverables'].include? name
|
|
||||||
wp['deliverables'][name] = deliverables[name]
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
puts " Ignored: #{args}"
|
puts " Ignored: #{args}"
|
||||||
end
|
end
|
||||||
@ -412,9 +352,10 @@ def load_pdata(proposal_dir)
|
|||||||
}
|
}
|
||||||
wp = workpackages.values.find {|wp| wp['label'] == wpid}
|
wp = workpackages.values.find {|wp| wp['label'] == wpid}
|
||||||
wp['deliverables'].push(deliverable)
|
wp['deliverables'].push(deliverable)
|
||||||
|
wp['deliverables'].sort_by! {|d| d['label']}
|
||||||
end
|
end
|
||||||
|
|
||||||
return workpackages
|
return workpackages.values.sort_by {|wp| wp['label']}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -425,7 +366,6 @@ check_token
|
|||||||
github = Octokit::Client.new(:netrc => true)
|
github = Octokit::Client.new(:netrc => true)
|
||||||
github.auto_paginate = true
|
github.auto_paginate = true
|
||||||
|
|
||||||
load_pdata(proposal_dir).each_value do |wp|
|
load_pdata(proposal_dir).each do |wp|
|
||||||
# puts JSON.pretty_generate(wp)
|
populate_workpackage(github, $repo, wp)
|
||||||
make_repo(github, wp)
|
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user