-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfork_neon.rb
executable file
·70 lines (62 loc) · 2.35 KB
/
fork_neon.rb
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env ruby
require 'octokit'
require 'concurrent'
Octokit.auto_paginate = true
@client = Octokit::Client.new
@threads = []
repos = `ssh [email protected]`.split("\n").collect { |x| x.split.last }
def new_or_update(name, component, repo)
retry_count = 0
gh_repo = "ds9-debian-#{component}/#{name}".freeze
begin
if @client.repository?(gh_repo)
begin
puts "Updating import for #{name} at ds9-debian-#{repo}"
@client.update_source_import(gh_repo, accept: 'application/vnd.github.barred-rock-preview')
status = 'running'
until %w[complete error].include?(status) do
sleep 5
status = @client.source_import_progress(gh_repo, accept: 'application/vnd.github.barred-rock-preview').status
end
raise "Error importing #{gh_repo}" if status == 'error'
rescue
retry_count += 1
if retry_count <= 10
retry
else
puts "Boo #{gh_repo}"
end
end
else
puts "Creating import for #{name} at ds9-debian-#{repo}"
@client.create_repository(name, organization: "ds9-debian-#{component}")
sleep 1 until @client.repository?(gh_repo)
@client.start_source_import(gh_repo, "git://anongit.neon.kde.org/#{repo}", accept: 'application/vnd.github.barred-rock-preview')
end
rescue Octokit::ServiceUnavailable, Octokit::UnprocessableEntity, Faraday::ConnectionFailed, Octokit::NotFound => e
case e
when Octokit::ServiceUnavailable, Faraday::ConnectionFailed
retry
when Octokit::UnprocessableEntity, Octokit::NotFound
puts "Boo: #{gh_repo}"
end
end
end
pool =
Concurrent::ThreadPoolExecutor.new(
min_threads: 2,
max_threads: 2,
max_queue: 512,
fallback_policy: :caller_runs
)
repos.each do |repo|
next unless repo&.include?('/')
component, *_, name = repo.split('/')
next if %w[calamares-settings-debian kobby qt-simulator].include?(name)
next unless ARGV.include?(component)
next unless name.include?('kholidays')
@threads << Concurrent::Promise.execute(executor: pool) do
new_or_update(name, component, repo)
end
end
@threads.collect(&:value!)