mergem 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dd0693ba937a1a8efeb0f7a595e926513cf6c1b1c0a418290de309ff497e9736
4
- data.tar.gz: 4f5924d99386028c17b4ccb99477d8cf8cc77161a337511ecf510dfcb801d428
3
+ metadata.gz: e9692bb5c82c39bd4a5730d6f7ac9c156bb19f0703ba8526d5048a33acadd073
4
+ data.tar.gz: 0d6f2e6b5e752ecc9a1af787b8456492b7156a873aff0dde3b6d96fb76030628
5
5
  SHA512:
6
- metadata.gz: b165ed9e1f03ce100f82cb44a06b3ba39c92cffbb34639c313cb3f46e1158cc791e2b8562cfe32e3a28aecd5e62dbb0b5798e904dd68cf8f10311fd44dd09193
7
- data.tar.gz: 707240dee88bdd74e85c2c59526d5434386ceaf8d7fff3247fa3965bddbd9f8cc640336a167387c74cd9a718b2c15bbf872ce706626d9ccd83dd0a08480e5920
6
+ metadata.gz: 8e731b2de572d25f816c49187cbc722472bc5570be6151c3d30f883901dffafd7f17dde5fca668ca134b2b2e35f8c10ca72a108060928756682171292530fb2f
7
+ data.tar.gz: 52766a9addf6021b7c0603f09da7518a3db6fe8c00446e2e0c6066a650d4f6fa5a3a98592427e6ec6557375c8769a19a8abce9476d7c794b310af8d720672e51
@@ -2,21 +2,26 @@
2
2
  name: cron
3
3
  on:
4
4
  schedule:
5
- - cron: '0,15,30,45 * * * *'
5
+ - cron: '17 * * * *'
6
6
  jobs:
7
7
  cron:
8
- runs-on: ubuntu-20.04
8
+ runs-on: ubuntu-22.04
9
9
  steps:
10
- - uses: actions/checkout@v3
11
- - uses: actions/cache@v3
12
- with:
13
- path: .mergem-cache
14
- key: main
10
+ - uses: actions/checkout@v4
15
11
  - uses: ruby/setup-ruby@v1
16
12
  with:
17
- ruby-version: ${{ matrix.ruby }}
13
+ ruby-version: 3.0
18
14
  - run: bundle update
15
+ - run: bundle exec rake rubocop
19
16
  - run: |
20
- bin/mergem --verbose --token=${{ secrets.TOKEN }} \
21
- --repo=yegor256/mergem \
22
- --repo=yegor256/iri
17
+ # --github-cache=yegor256/mergem/cache/latest.txt \
18
+ bin/mergem --verbose \
19
+ --token=${{ secrets.TOKEN }} \
20
+ --repo=yegor256/* \
21
+ --repo=objectionary/* \
22
+ --repo=polystat/* \
23
+ --repo=sttc/* \
24
+ --repo=zold-io/* \
25
+ --repo=jcabi/* \
26
+ --exclude=objectionary/ineo-maven-plugin \
27
+ --exclude=objectionary/jeo-maven-plugin
@@ -5,7 +5,7 @@ on:
5
5
  pull_request:
6
6
  jobs:
7
7
  pdd:
8
- runs-on: ubuntu-20.04
8
+ runs-on: ubuntu-22.04
9
9
  steps:
10
- - uses: actions/checkout@v3
10
+ - uses: actions/checkout@v4
11
11
  - uses: g4s8/pdd-action@master
@@ -15,7 +15,7 @@ jobs:
15
15
  ruby: ['2.7', '3.0']
16
16
  runs-on: ${{ matrix.os }}
17
17
  steps:
18
- - uses: actions/checkout@v3
18
+ - uses: actions/checkout@v4
19
19
  - uses: ruby/setup-ruby@v1
20
20
  with:
21
21
  ruby-version: ${{ matrix.ruby }}
@@ -5,7 +5,7 @@ on:
5
5
  pull_request:
6
6
  jobs:
7
7
  xcop:
8
- runs-on: ubuntu-20.04
8
+ runs-on: ubuntu-22.04
9
9
  steps:
10
- - uses: actions/checkout@v3
10
+ - uses: actions/checkout@v4
11
11
  - uses: g4s8/xcop-action@master
data/.gitignore CHANGED
@@ -5,4 +5,4 @@ Gemfile.lock
5
5
  .bundle/
6
6
  .DS_Store
7
7
  rdoc/
8
- /mergem/
8
+ .mergem-cache
data/.rubocop.yml CHANGED
@@ -21,3 +21,5 @@ Layout/EmptyLineAfterGuardClause:
21
21
  Enabled: false
22
22
  Style/ClassAndModuleChildren:
23
23
  Enabled: false
24
+ Metrics/PerceivedComplexity:
25
+ Enabled: false
data/.simplecov CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2022 Yegor Bugayenko
1
+ # Copyright (c) 2022-2023 Yegor Bugayenko
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  # of this software and associated documentation files (the 'Software'), to deal
@@ -33,6 +33,6 @@ else
33
33
  SimpleCov.start do
34
34
  add_filter '/test/'
35
35
  add_filter '/features/'
36
- minimum_coverage 80
36
+ minimum_coverage 30
37
37
  end
38
38
  end
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2022 Yegor Bugayenko
1
+ # Copyright (c) 2022-2023 Yegor Bugayenko
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  # of this software and associated documentation files (the 'Software'), to deal
@@ -20,3 +20,12 @@
20
20
 
21
21
  source 'https://rubygems.org'
22
22
  gemspec
23
+
24
+ gem 'cucumber', '9.0.2', require: false
25
+ gem 'minitest', '5.20.0', require: false
26
+ gem 'rake', '13.1.0', require: false
27
+ gem 'rdoc', '6.6.0', require: false
28
+ gem 'rubocop', '1.52.1', require: false
29
+ gem 'rubocop-rspec', '2.25.0', require: false
30
+ gem 'simplecov', '0.22.0', require: false
31
+ gem 'xcop', '0.7.1', require: false
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  (The MIT License)
2
2
 
3
- Copyright (c) 2022 Yegor Bugayenko
3
+ Copyright (c) 2022-2023 Yegor Bugayenko
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the 'Software'), to deal
data/README.md CHANGED
@@ -1,14 +1,10 @@
1
- <img alt="mergem logo" src="/logo.svg" width="64px"/>
2
-
3
1
  [![EO principles respected here](https://www.elegantobjects.org/badge.svg)](https://www.elegantobjects.org)
4
2
  [![DevOps By Rultor.com](http://www.rultor.com/b/yegor256/mergem)](http://www.rultor.com/p/yegor256/mergem)
5
3
  [![We recommend RubyMine](https://www.elegantobjects.org/rubymine.svg)](https://www.jetbrains.com/ruby/)
6
4
 
7
5
  [![rake](https://github.com/yegor256/mergem/actions/workflows/rake.yml/badge.svg)](https://github.com/yegor256/mergem/actions/workflows/rake.yml)
8
- [![PDD status](http://www.0pdd.com/svg?name=yegor256/mergem)](http://www.0pdd.com/p?name=yegor256/mergem)
9
6
  [![Gem Version](https://badge.fury.io/rb/mergem.svg)](http://badge.fury.io/rb/mergem)
10
7
  [![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/yegor256/mergem/blob/master/LICENSE.txt)
11
- [![Maintainability](https://api.codeclimate.com/v1/badges/396ec0584e0a84adc723/maintainability)](https://codeclimate.com/github/yegor256/mergem/maintainability)
12
8
  [![Test Coverage](https://img.shields.io/codecov/c/github/yegor256/mergem.svg)](https://codecov.io/github/yegor256/mergem?branch=master)
13
9
  ![Lines of code](https://img.shields.io/tokei/lines/github/yegor256/mergem)
14
10
  [![Hits-of-Code](https://hitsofcode.com/github/yegor256/mergem)](https://hitsofcode.com/view/github/yegor256/mergem)
@@ -26,12 +22,54 @@ Then, run it locally and read its output:
26
22
  $ mergem --repo yegor256/mergem --verbose --token <YOUR_GITHUB_TOKEN>
27
23
  ```
28
24
 
25
+ First, it will find all pull requests in `yegor256/mergem` GitHub repository,
26
+ which were not yet discussed by the owner of the token. Then, it will ignore
27
+ those pull requests that are coming not
28
+ from [Renovate](https://github.com/apps/renovate)
29
+ or [Dependabot](https://github.com/dependabot). Then, it will
30
+ post `@rultor merge` text message to each pull request left in the list.
31
+
32
+ ## Token
33
+
34
+ `mergem` requires a GitHub token to be passed via the `--token` option. To
35
+ obtain one, go to your GitHub account, then navigate to "Settings," and then
36
+ to "Developer Settings" (or simply use
37
+ the [link](https://github.com/settings/tokens).)
38
+
39
+ ### Classic Token
40
+
41
+ You can create a classic token with the `public_repo` ("Access public
42
+ repositories") scope. It will grant `mergem` all the necessary permissions to
43
+ read and write comments on repositories.
44
+
45
+ ### Fine-grained Token
46
+
47
+ Another option is to create a fine-grained token with "All Repositories" access.
48
+ In this case, you will need to assign the following permissions to the token:
49
+
50
+ * Issues, "Read and write"
51
+ * Pull requests, "Read and write"
52
+ * Contents, "Read and write"
53
+
54
+ Please note that fine-grained tokens might encounter issues with repositories
55
+ not owned by you or owned by an organization. In such cases, you may need to
56
+ obtain additional approval from the organization.
57
+
58
+ > During the beta, organizations must opt in to fine-grained personal access
59
+ > tokens. If your organization has not already opted-in, then you will be
60
+ > prompted
61
+ > to opt-in and set policies when you follow the steps below.
62
+
63
+ You can find information about setting a personal access token policy for your
64
+ organization
65
+ right [here](https://docs.github.com/en/organizations/managing-programmatic-access-to-your-organization/setting-a-personal-access-token-policy-for-your-organization).
66
+
29
67
  ## How to contribute
30
68
 
31
69
  Read [these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).
32
- Make sure you build is green before you contribute
33
- your pull request. You will need to have [Ruby](https://www.ruby-lang.org/en/) 2.3+ and
34
- [Bundler](https://bundler.io/) installed. Then:
70
+ Make sure you build is green before you contribute your pull request. You will
71
+ need to have [Ruby](https://www.ruby-lang.org/en/) 2.3+
72
+ and [Bundler](https://bundler.io/) installed. Then:
35
73
 
36
74
  ```
37
75
  $ bundle update
@@ -39,3 +77,9 @@ $ bundle exec rake
39
77
  ```
40
78
 
41
79
  If it's clean and you don't see any error messages, submit your pull request.
80
+
81
+ In order to run a single test:
82
+
83
+ ```
84
+ $ bundle exec ruby test/test_askrultor.rb
85
+ ```
data/Rakefile CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2022 Yegor Bugayenko
1
+ # Copyright (c) 2022-2023 Yegor Bugayenko
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  # of this software and associated documentation files (the 'Software'), to deal
data/bin/mergem CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- # Copyright (c) 2022 Yegor Bugayenko
2
+ # Copyright (c) 2022-2023 Yegor Bugayenko
3
3
  #
4
4
  # Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  # of this software and associated documentation files (the 'Software'), to deal
@@ -24,11 +24,15 @@ STDOUT.sync = true
24
24
  require 'slop'
25
25
  require 'loog'
26
26
  require 'octokit'
27
+ require 'digest'
28
+ require 'tacky'
27
29
  require 'backtrace'
28
30
  require 'fileutils'
29
31
  require 'obk'
30
32
  require_relative '../lib/mergem/version'
31
33
  require_relative '../lib/mergem/pulls'
34
+ require_relative '../lib/mergem/repos'
35
+ require_relative '../lib/mergem/askrultor'
32
36
 
33
37
  loog = Loog::REGULAR
34
38
 
@@ -48,9 +52,11 @@ opts = Slop.parse(args, strict: true, help: true) do |o|
48
52
  o.bool '--verbose', 'Print as much log messages as possible'
49
53
  o.bool '--dry', 'Make no real round trips to GitHub'
50
54
  o.string '--cache', 'Use this file as a cache, to avoid duplicated roudtrips to GitHub', default: '.mergem-cache'
51
- o.integer '--delay', 'Delay between HTTP calls to GitHub API, in milliseconds', default: 1000
55
+ o.string '--github-cache', 'Place in GitHub for cache file, e.g. "yegor256/mergem/cache/latest.txt" (repo, branch, path)'
56
+ o.integer '--delay', 'Delay between HTTP calls to GitHub API, in milliseconds', default: 100
52
57
  o.string '--token', 'GitHub authentication token'
53
- o.array '--repo', 'GitHub repo to check, e.g. yegor256/blog'
58
+ o.array '--repo', 'GitHub repo to check, e.g. yegor256/blog or yegor256/*'
59
+ o.array '--exclude', 'GitHub repository to exclude (no mask here, just name)'
54
60
  end
55
61
 
56
62
  if opts.help?
@@ -78,31 +84,70 @@ def api(opts, loog)
78
84
  loog.warn("Connecting to GitHub without a token, this may lead to errors, use --token")
79
85
  end
80
86
  api.auto_paginate = true
81
- Obk.new(api, pause: opts[:delay])
87
+ Tacky.new(Obk.new(api, pause: opts[:delay]))
82
88
  end
83
89
 
84
90
  begin
91
+ api = api(opts, loog)
85
92
  cache = File.absolute_path(opts[:cache])
93
+ blog = ''
94
+ if opts['github-cache']
95
+ org, repo, branch, path = opts['github-cache'].split('/', 4)
96
+ c = api.contents("#{org}/#{repo}", path: path, ref: branch)
97
+ File.write(cache, c[:content])
98
+ loog.info("Cache is taken from '#{org}/#{repo}' (#{File.readlines(cache).count} lines)")
99
+ sha = c[:sha]
100
+ loog.info("SHA of cache is '#{sha}'")
101
+ end
86
102
  if File.exist?(cache)
87
- loog.debug("Cache file is '#{cache}' (#{File.readlines(cache)} lines)")
103
+ loog.debug("Cache file is '#{cache}' (#{File.readlines(cache).count} lines)")
88
104
  else
89
105
  File.write(cache, '')
90
106
  loog.debug("Cache file '#{cache}' was absent")
91
107
  end
92
- api = api(opts, loog)
93
108
  if opts.dry?
94
109
  total = 1
95
110
  else
96
- total = Mergem::Pulls.new(api, loog, opts[:repo]).each do |repo, pr|
97
- title = "#{repo}/##{pr}"
98
- next unless File.readlines(cache).find(title).nil?
99
- Mergem::AskRultor.new(api, loog).ask(repo, pr)
100
- open(cache, 'a') { |f| f.puts title }
101
- loog.info("#{title} checked")
111
+ seen = File.readlines(cache, chomp: true).map { |t| t.strip }
112
+ total = 0
113
+ Mergem::Repos.new(api, loog, opts[:repo]).each do |repo|
114
+ if opts[:exclude].include?(repo)
115
+ loog.debug("'#{repo}' skipped because of --exclude")
116
+ next
117
+ end
118
+ total += Mergem::Pulls.new(api, loog, repo).each do |pr|
119
+ title = "#{repo}##{pr}"
120
+ if seen.include?(title)
121
+ loog.debug("'#{title}' is already in cache, skipping it")
122
+ next
123
+ end
124
+ if Mergem::AskRultor.new(api, loog).ask(repo, pr)
125
+ seen << title
126
+ loog.info("#{title} checked")
127
+ else
128
+ loog.info("#{title} must be checked later")
129
+ end
130
+ end
102
131
  end
132
+ File.write(cache, seen.join("\n"))
103
133
  end
104
134
  loog.debug("#{total} PRs processed")
135
+ loog.debug("There are #{File.readlines(cache).count} lines in the cache file '#{cache}'")
136
+ if opts['github-cache']
137
+ org, repo, branch, path = opts['github-cache'].split('/', 4)
138
+ lines = File.readlines(cache).count
139
+ if lines > 5000
140
+ head = lines - 5000
141
+ File.write(cache, File.readlines(cache).drop(head).join)
142
+ loog.info("Cache file is too long, we removed #{head} lines from its head")
143
+ end
144
+ api.update_contents(
145
+ "#{org}/#{repo}", path, "#{File.readlines(cache).count} lines",
146
+ sha, File.read(cache), branch: branch, file: cache
147
+ )
148
+ loog.info("Cache file was placed to '#{org}/#{repo}' (#{lines} lines)")
149
+ end
105
150
  rescue StandardError => e
106
151
  loog.error(Backtrace.new(e))
107
- exit -1
152
+ exit 1
108
153
  end
data/features/cli.feature CHANGED
@@ -14,3 +14,8 @@ Feature: Simple Reporting
14
14
  When I run bin/mergem with "--repo yegor256/mergem --dry --verbose"
15
15
  Then Stdout contains "1 PRs processed"
16
16
  And Exit code is zero
17
+
18
+ Scenario: Skip all repos
19
+ When I run bin/mergem with "--repo yegor256/mergem --exclude yegor256/mergem --verbose"
20
+ Then Stdout contains "skipped"
21
+ And Exit code is zero
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2022 Yegor Bugayenko
1
+ # Copyright (c) 2022-2023 Yegor Bugayenko
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  # of this software and associated documentation files (the 'Software'), to deal
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2022 Yegor Bugayenko
1
+ # Copyright (c) 2022-2023 Yegor Bugayenko
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  # of this software and associated documentation files (the 'Software'), to deal
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2022 Yegor Bugayenko
1
+ # Copyright (c) 2022-2023 Yegor Bugayenko
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  # of this software and associated documentation files (the 'Software'), to deal
@@ -20,13 +20,13 @@
20
20
 
21
21
  # Ask Rultor to merge a pull request.
22
22
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
23
- # Copyright:: Copyright (c) 2022 Yegor Bugayenko
23
+ # Copyright:: Copyright (c) 2022-2023 Yegor Bugayenko
24
24
  # License:: MIT
25
25
  class Mergem::AskRultor
26
26
  def initialize(api, loog)
27
27
  @api = api
28
28
  @loog = loog
29
- @bots = ['renovate[bot]']
29
+ @bots = ['renovate[bot]', 'dependabot[bot]', 'dependabot-preview[bot]']
30
30
  end
31
31
 
32
32
  def ask(repo, num)
@@ -34,14 +34,39 @@ class Mergem::AskRultor
34
34
  user = @api.user[:login]
35
35
  rescue Octokit::Unauthorized
36
36
  user = 'yegor256'
37
- @loog.debug('You are not using GitHub token...')
37
+ @loog.debug('You are not using GitHub token :( Try to use --token option.')
38
38
  end
39
39
  issue = @api.issue(repo, num)
40
- return false unless @bots.include?(issue[:user][:login])
40
+ title = "#{repo}##{num}"
41
+ author = issue[:user][:login]
42
+ unless @bots.include?(author)
43
+ @loog.debug("#{title} is authored by @#{author} (not a bot)")
44
+ return true
45
+ end
41
46
  json = @api.issue_comments(repo, num)
42
- @loog.debug("Found #{json.count} comments in #{repo}##{num}")
43
- return false unless json.find { |j| j[:user][:login] == user }.nil?
44
- @api.add_comment(repo, num, '@rultor please, try to merge')
47
+ @loog.debug("Found #{json.count} comments in #{title}")
48
+ unless json.find { |j| j[:user][:login] == user }.nil?
49
+ @loog.debug("#{title} was already discussed by @#{user}")
50
+ return true
51
+ end
52
+ sha = @api.pull_request(repo, num)[:head][:sha]
53
+ checks = @api.check_runs_for_ref(repo, sha)[:check_runs]
54
+ checks.each do |check|
55
+ if check[:status] != 'completed'
56
+ @loog.debug("Check #{check[:id]} at #{title} is still running, let's try to merge later")
57
+ return false
58
+ end
59
+ if check[:conclusion] != 'success'
60
+ @loog.debug("Check #{check[:id]} at #{title} failed, no reason to try to merge")
61
+ return true
62
+ end
63
+ @loog.debug("Check #{check[:id]} at #{title} is '#{check[:status]}/#{check[:conclusion]}', good!")
64
+ end
65
+ @loog.debug("All #{checks.count} check(s) completed successfully in #{title}")
66
+ msg = '@rultor please, try to merge'
67
+ msg += ", since #{checks.count} checks have passed" if checks.count > 0
68
+ @api.add_comment(repo, num, msg)
69
+ @loog.info("Comment added to #{title}")
45
70
  true
46
71
  end
47
72
  end
data/lib/mergem/pulls.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2022 Yegor Bugayenko
1
+ # Copyright (c) 2022-2023 Yegor Bugayenko
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  # of this software and associated documentation files (the 'Software'), to deal
@@ -20,24 +20,22 @@
20
20
 
21
21
  # Pulls in GitHub API.
22
22
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
23
- # Copyright:: Copyright (c) 2022 Yegor Bugayenko
23
+ # Copyright:: Copyright (c) 2022-2023 Yegor Bugayenko
24
24
  # License:: MIT
25
25
  class Mergem::Pulls
26
- def initialize(api, loog, repos)
26
+ def initialize(api, loog, repo)
27
27
  @api = api
28
28
  @loog = loog
29
- @repos = repos
29
+ @repo = repo
30
30
  end
31
31
 
32
32
  def each
33
+ json = @api.pull_requests(@repo, state: 'open')
34
+ @loog.debug("Found #{json.count} pull requests in #{@repo}")
33
35
  total = 0
34
- @repos.each do |repo|
35
- json = @api.pull_requests(repo, state: 'open')
36
- @loog.debug("Found #{json.count} pull requests in #{repo}")
37
- json.each do |p|
38
- yield repo, p[:number]
39
- total += 1
40
- end
36
+ json.each do |p|
37
+ yield p[:number]
38
+ total += 1
41
39
  end
42
40
  total
43
41
  end
@@ -0,0 +1,58 @@
1
+ # Copyright (c) 2022-2023 Yegor Bugayenko
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the 'Software'), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in all
11
+ # copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ # SOFTWARE.
20
+
21
+ # Find all repositories by the locations provided.
22
+ # Author:: Yegor Bugayenko (yegor256@gmail.com)
23
+ # Copyright:: Copyright (c) 2022-2023 Yegor Bugayenko
24
+ # License:: MIT
25
+ class Mergem::Repos
26
+ def initialize(api, loog, masks)
27
+ @api = api
28
+ @loog = loog
29
+ @masks = masks
30
+ end
31
+
32
+ def each
33
+ total = 0
34
+ names = []
35
+ @masks.each do |repo|
36
+ if repo.end_with?('/*')
37
+ org = repo.split('/')[0]
38
+ @api.repositories(org).each do |r|
39
+ n = r['full_name']
40
+ @loog.debug("Found #{n} repo in @#{org}")
41
+ names << n
42
+ end
43
+ else
44
+ names << repo
45
+ end
46
+ end
47
+ names.each do |n|
48
+ r = @api.repository(n)
49
+ if r[:archived]
50
+ @loog.debug("Repository #{n} is archived, ignoring")
51
+ next
52
+ end
53
+ yield n
54
+ total += 1
55
+ end
56
+ total
57
+ end
58
+ end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2022 Yegor Bugayenko
1
+ # Copyright (c) 2022-2023 Yegor Bugayenko
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  # of this software and associated documentation files (the 'Software'), to deal
@@ -20,8 +20,8 @@
20
20
 
21
21
  # mergem main module.
22
22
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
23
- # Copyright:: Copyright (c) 2022 Yegor Bugayenko
23
+ # Copyright:: Copyright (c) 2022-2023 Yegor Bugayenko
24
24
  # License:: MIT
25
25
  module Mergem
26
- VERSION = '0.0.2'.freeze
26
+ VERSION = '0.0.3'.freeze
27
27
  end
data/mergem.gemspec CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2022 Yegor Bugayenko
1
+ # Copyright (c) 2022-2023 Yegor Bugayenko
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  # of this software and associated documentation files (the 'Software'), to deal
@@ -44,15 +44,8 @@ Gem::Specification.new do |s|
44
44
  s.add_runtime_dependency 'iri', '~>0.5'
45
45
  s.add_runtime_dependency 'loog', '~>0.2'
46
46
  s.add_runtime_dependency 'obk', '0.3.0'
47
- s.add_runtime_dependency 'octokit', '~>4.0'
47
+ s.add_runtime_dependency 'octokit', '~>6.0'
48
48
  s.add_runtime_dependency 'rainbow', '~>3.0'
49
49
  s.add_runtime_dependency 'slop', '~>4.4'
50
- s.add_development_dependency 'codecov', '0.6.0'
51
- s.add_development_dependency 'cucumber', '8.0.0'
52
- s.add_development_dependency 'minitest', '5.15.0'
53
- s.add_development_dependency 'rake', '13.0.6'
54
- s.add_development_dependency 'rdoc', '6.4.0'
55
- s.add_development_dependency 'rubocop', '1.32.0'
56
- s.add_development_dependency 'rubocop-rspec', '2.11.1'
57
- s.add_development_dependency 'xcop', '0.7.1'
50
+ s.add_runtime_dependency 'tacky', '~>0.3'
58
51
  end
data/renovate.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
+ "extends": [
4
+ "config:base"
5
+ ]
6
+ }
data/test/test__helper.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2022 Yegor Bugayenko
1
+ # Copyright (c) 2022-2023 Yegor Bugayenko
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  # of this software and associated documentation files (the 'Software'), to deal
@@ -22,9 +22,5 @@ $stdout.sync = true
22
22
 
23
23
  require 'simplecov'
24
24
  SimpleCov.start
25
- if ENV['CI'] == 'true'
26
- require 'codecov'
27
- SimpleCov.formatter = SimpleCov::Formatter::Codecov
28
- end
29
25
 
30
26
  require 'minitest/autorun'
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2022 Yegor Bugayenko
1
+ # Copyright (c) 2022-2023 Yegor Bugayenko
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  # of this software and associated documentation files (the 'Software'), to deal
@@ -25,14 +25,14 @@ require_relative '../lib/mergem/askrultor'
25
25
 
26
26
  # Test for AskRultor.
27
27
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
28
- # Copyright:: Copyright (c) 2022 Yegor Bugayenko
28
+ # Copyright:: Copyright (c) 2022-2023 Yegor Bugayenko
29
29
  # License:: MIT
30
30
  class TestAskRultor < Minitest::Test
31
31
  def test_real
32
32
  api = Octokit::Client.new
33
33
  m = Mergem::AskRultor.new(api, Loog::VERBOSE)
34
34
  asked = m.ask('yegor256/mergem', 1)
35
- assert(!asked)
35
+ assert(asked)
36
36
  rescue Octokit::TooManyRequests => e
37
37
  puts e.message
38
38
  skip
data/test/test_pulls.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2022 Yegor Bugayenko
1
+ # Copyright (c) 2022-2023 Yegor Bugayenko
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  # of this software and associated documentation files (the 'Software'), to deal
@@ -25,15 +25,15 @@ require_relative '../lib/mergem/pulls'
25
25
 
26
26
  # Test for Pulls.
27
27
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
28
- # Copyright:: Copyright (c) 2022 Yegor Bugayenko
28
+ # Copyright:: Copyright (c) 2022-2023 Yegor Bugayenko
29
29
  # License:: MIT
30
30
  class TestPulls < Minitest::Test
31
31
  def test_real
32
32
  api = Octokit::Client.new
33
- m = Mergem::Pulls.new(api, Loog::VERBOSE, ['yegor256/blog'])
33
+ m = Mergem::Pulls.new(api, Loog::VERBOSE, 'yegor256/blog')
34
34
  ms = []
35
- total = m.each do |repo, pr|
36
- ms << "#{repo}##{pr}"
35
+ total = m.each do |pr|
36
+ ms << "##{pr}"
37
37
  end
38
38
  assert(!ms.empty?)
39
39
  assert_equal(total, ms.count)
@@ -0,0 +1,54 @@
1
+ # Copyright (c) 2022-2023 Yegor Bugayenko
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the 'Software'), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in all
11
+ # copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ # SOFTWARE.
20
+
21
+ require 'minitest/autorun'
22
+ require 'octokit'
23
+ require 'loog'
24
+ require_relative '../lib/mergem/repos'
25
+
26
+ # Test for Repos.
27
+ # Author:: Yegor Bugayenko (yegor256@gmail.com)
28
+ # Copyright:: Copyright (c) 2022-2023 Yegor Bugayenko
29
+ # License:: MIT
30
+ class TestPulls < Minitest::Test
31
+ def test_find_real
32
+ api = Octokit::Client.new
33
+ r = Mergem::Repos.new(api, Loog::VERBOSE, ['yegor256/blog', 'polystat/*'])
34
+ ms = []
35
+ total = r.each do |repo|
36
+ ms << repo
37
+ end
38
+ assert(!ms.empty?)
39
+ assert_equal(total, ms.count)
40
+ p ms
41
+ rescue Octokit::TooManyRequests => e
42
+ puts e.message
43
+ skip
44
+ end
45
+
46
+ def test_ignore_archived
47
+ api = Octokit::Client.new
48
+ r = Mergem::Repos.new(api, Loog::VERBOSE, ['yegor256/netbout'])
49
+ assert_equal(0, r.each)
50
+ rescue Octokit::TooManyRequests => e
51
+ puts e.message
52
+ skip
53
+ end
54
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mergem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-04 00:00:00.000000000 Z
11
+ date: 2023-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backtrace
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '4.0'
75
+ version: '6.0'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '4.0'
82
+ version: '6.0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rainbow
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -109,117 +109,19 @@ dependencies:
109
109
  - !ruby/object:Gem::Version
110
110
  version: '4.4'
111
111
  - !ruby/object:Gem::Dependency
112
- name: codecov
112
+ name: tacky
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - '='
116
- - !ruby/object:Gem::Version
117
- version: 0.6.0
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - '='
123
- - !ruby/object:Gem::Version
124
- version: 0.6.0
125
- - !ruby/object:Gem::Dependency
126
- name: cucumber
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - '='
130
- - !ruby/object:Gem::Version
131
- version: 8.0.0
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - '='
137
- - !ruby/object:Gem::Version
138
- version: 8.0.0
139
- - !ruby/object:Gem::Dependency
140
- name: minitest
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - '='
144
- - !ruby/object:Gem::Version
145
- version: 5.15.0
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - '='
151
- - !ruby/object:Gem::Version
152
- version: 5.15.0
153
- - !ruby/object:Gem::Dependency
154
- name: rake
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - '='
158
- - !ruby/object:Gem::Version
159
- version: 13.0.6
160
- type: :development
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - '='
165
- - !ruby/object:Gem::Version
166
- version: 13.0.6
167
- - !ruby/object:Gem::Dependency
168
- name: rdoc
169
- requirement: !ruby/object:Gem::Requirement
170
- requirements:
171
- - - '='
172
- - !ruby/object:Gem::Version
173
- version: 6.4.0
174
- type: :development
175
- prerelease: false
176
- version_requirements: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - '='
179
- - !ruby/object:Gem::Version
180
- version: 6.4.0
181
- - !ruby/object:Gem::Dependency
182
- name: rubocop
183
- requirement: !ruby/object:Gem::Requirement
184
- requirements:
185
- - - '='
186
- - !ruby/object:Gem::Version
187
- version: 1.32.0
188
- type: :development
189
- prerelease: false
190
- version_requirements: !ruby/object:Gem::Requirement
191
- requirements:
192
- - - '='
193
- - !ruby/object:Gem::Version
194
- version: 1.32.0
195
- - !ruby/object:Gem::Dependency
196
- name: rubocop-rspec
197
- requirement: !ruby/object:Gem::Requirement
198
- requirements:
199
- - - '='
200
- - !ruby/object:Gem::Version
201
- version: 2.11.1
202
- type: :development
203
- prerelease: false
204
- version_requirements: !ruby/object:Gem::Requirement
205
- requirements:
206
- - - '='
207
- - !ruby/object:Gem::Version
208
- version: 2.11.1
209
- - !ruby/object:Gem::Dependency
210
- name: xcop
211
- requirement: !ruby/object:Gem::Requirement
212
- requirements:
213
- - - '='
115
+ - - "~>"
214
116
  - !ruby/object:Gem::Version
215
- version: 0.7.1
216
- type: :development
117
+ version: '0.3'
118
+ type: :runtime
217
119
  prerelease: false
218
120
  version_requirements: !ruby/object:Gem::Requirement
219
121
  requirements:
220
- - - '='
122
+ - - "~>"
221
123
  - !ruby/object:Gem::Version
222
- version: 0.7.1
124
+ version: '0.3'
223
125
  description: tbd...
224
126
  email: yegor256@gmail.com
225
127
  executables:
@@ -251,11 +153,14 @@ files:
251
153
  - features/support/env.rb
252
154
  - lib/mergem/askrultor.rb
253
155
  - lib/mergem/pulls.rb
156
+ - lib/mergem/repos.rb
254
157
  - lib/mergem/version.rb
255
158
  - mergem.gemspec
159
+ - renovate.json
256
160
  - test/test__helper.rb
257
161
  - test/test_askrultor.rb
258
162
  - test/test_pulls.rb
163
+ - test/test_repos.rb
259
164
  homepage: http://github.com/yegor256/mergem
260
165
  licenses:
261
166
  - MIT