Skip to content

Commit

Permalink
Merge pull request #49 from Yegorov/46
Browse files Browse the repository at this point in the history
#46: ignore archived repositories for Fbe#unmask_repos
  • Loading branch information
yegor256 authored Aug 2, 2024
2 parents 333d422 + 6bc7d02 commit 2f21bbb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/fbe/octo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def repository(name)
has_pages: false,
has_discussions: false,
forks_count: 0,
archived: false,
archived: name == 'zerocracy/datum',
disabled: false,
open_issues_count: 6,
license: { key: 'mit', name: 'MIT License' },
Expand Down
4 changes: 3 additions & 1 deletion lib/fbe/unmask_repos.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,23 @@ def self.mask_to_regex(mask)

def self.unmask_repos(options: $options, global: $global, loog: $loog)
repos = []
octo = Fbe.octo(loog:, global:, options:)
masks = (options.repositories || '').split(',')
masks.reject { |m| m.start_with?('-') }.each do |mask|
unless mask.include?('*')
repos << mask
next
end
re = Fbe.mask_to_regex(mask)
Fbe.octo(loog:, global:, options:).repositories(mask.split('/')[0]).each do |r|
octo.repositories(mask.split('/')[0]).each do |r|
repos << r[:full_name] if re.match?(r[:full_name])
end
end
masks.select { |m| m.start_with?('-') }.each do |mask|
re = Fbe.mask_to_regex(mask[1..])
repos.reject! { |r| re.match?(r) }
end
repos.reject! { |repo| octo.repository(repo)[:archived] }
raise "No repos found matching: #{options.repositories}" if repos.empty?
loog.debug("Scanning #{repos.size} repositories: #{repos.join(', ')}...")
repos
Expand Down
11 changes: 7 additions & 4 deletions test/fbe/test_unmask_repos.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,25 @@ def test_simple_use
opts = Judges::Options.new(
{
'testing' => true,
'repositories' => 'yegor256/tacit,zerocracy/*,-zerocracy/judges-action'
'repositories' => 'yegor256/tacit,zerocracy/*,-zerocracy/judges-action,zerocracy/datum'
}
)
assert(Fbe.unmask_repos(options: opts, global: {}, loog: Loog::NULL).size.positive?)
list = Fbe.unmask_repos(options: opts, global: {}, loog: Loog::NULL)
assert(list.size.positive?)
refute_includes(list, 'zerocracy/datum')
end

def test_live_usage
skip('Run it only manually, since it touches GitHub API')
Judges::Options.new(
opts = Judges::Options.new(
{
'repositories' => 'zerocracy/*,-zerocracy/judges-action'
'repositories' => 'zerocracy/*,-zerocracy/judges-action,zerocracy/datum'
}
)
list = Fbe.unmask_repos(options: opts, global: {}, loog: Loog::NULL)
assert(list.size.positive?)
assert(list.include?('zerocracy/pages-action'))
assert(!list.include?('zerocracy/judges-action'))
refute_includes(list, 'zerocracy/datum')
end
end

0 comments on commit 2f21bbb

Please sign in to comment.