Class: Fief::Repos
- Inherits:
-
Object
- Object
- Fief::Repos
- Defined in:
- lib/fief/repos.rb
Overview
Fetch all repos required by the options.
- Author
-
Yegor Bugayenko ([email protected])
- Copyright
-
Copyright © 2023 Yegor Bugayenko
- License
-
MIT
Instance Method Summary collapse
- #all ⇒ Object
-
#initialize(opts, api, loog) ⇒ Repos
constructor
A new instance of Repos.
Constructor Details
#initialize(opts, api, loog) ⇒ Repos
Returns a new instance of Repos.
28 29 30 31 32 |
# File 'lib/fief/repos.rb', line 28 def initialize(opts, api, loog) @opts = opts @api = api @loog = loog end |
Instance Method Details
#all ⇒ Object
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 71 72 73 74 75 |
# File 'lib/fief/repos.rb', line 34 def all repos = [] @opts[:include].each do |mask| org, repo = mask.split('/') if repo == '*' if @api.user(org)[:type] == 'User' @loog.debug("GitHub account @#{org} is a user's account") @api.repositories(org, { type: 'public' }).each do |json| id = json[:full_name] if json[:archived] @loog.debug("The #{id} repo is archived, ignoring it") next end repos << id @loog.debug("Including #{id} as it is owned by @#{org}") end else @loog.debug("GitHub account @#{org} is an organization account") @api.organization_repositories(org, { type: 'public' }).each do |json| id = json[:full_name] if json[:archived] @loog.debug("The #{id} repo is archived, ignoring it") next end repos << id @loog.debug("Including #{id} as a member of @#{org} organization") end end else @loog.debug("Including #{org}/#{repo} as requested by --include") repos << mask end end repos.reject do |repo| if @opts[:exclude] && @opts[:exclude].any? { |m| Fief::Mask.new(m).matches?(repo) } @loog.debug("Excluding #{repo} due to --exclude") true else false end end end |