multi_repo 0.3.0 → 0.4.0

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: 437c3e990a7e7feb750b0a2d65744d076bc496ce3de3560d25d25f4df8b335e9
4
- data.tar.gz: 695fca5f0b5ac72a1b91130381be208202a0bfbfcb11f866a6ce7f98b867e478
3
+ metadata.gz: bc809429c529e0f58d2274708e0785944edf7170ce7aa23858fc88031bb593e1
4
+ data.tar.gz: 7d58ebc46fe2202b9e2e285e6a26fc4b4a40556181301a651994d41b9e4c1d5f
5
5
  SHA512:
6
- metadata.gz: fa5a942aabcf9a2ad1b04c594785992c9c553f58f7176d11d734707becbc09e02344dca9f0cba462e4a732e73b591e463f55f5dd9cd211bf5a6ed03bd9d6283b
7
- data.tar.gz: c89faaec5c8931c84fac5a4706316723a6eeaa16160b1770a2f9e4dc457bddc821cd401487e8f76f90cb967f2dcade5e785dfabd1c8ac45f3e00605d141fd468
6
+ metadata.gz: 4828418ee29894ce72fd5d2ab2e705b99854f1aa5ba26f321a0235bfa7c7eadf45a5aada881897aa5df16fb6f83cdd1968113af80e0163d2a13a9e4dd354ee2d
7
+ data.tar.gz: b4b2ed2d3c9677e658ad4c60ec615779882dee381bc5ed4b771602d56ca0a5b72ade124e140d50568a359c5e838d99ce3c51a8a475925a096d0582b7adc0cf9e
data/.codeclimate.yml CHANGED
@@ -12,5 +12,5 @@ plugins:
12
12
  rubocop:
13
13
  enabled: true
14
14
  config: ".rubocop_cc.yml"
15
- channel: rubocop-0-82
15
+ channel: rubocop-1-56-3
16
16
  version: '2'
@@ -17,7 +17,7 @@ jobs:
17
17
  env:
18
18
  CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
19
19
  steps:
20
- - uses: actions/checkout@v3
20
+ - uses: actions/checkout@v4
21
21
  - name: Set up Ruby
22
22
  uses: ruby/setup-ruby@v1
23
23
  with:
data/CHANGELOG.md ADDED
@@ -0,0 +1,23 @@
1
+ # Change Log
2
+ All notable changes to this project will be documented in this file.
3
+ This project adheres to [Semantic Versioning](http://semver.org/).
4
+
5
+ ## [Unreleased]
6
+
7
+ ## [0.4.0] - 2024-03-29
8
+ ### Changed
9
+ - Allow overriding the path for a repo [[#28](https://github.com/ManageIQ/multi_repo/pull/28)]
10
+
11
+ ### Fixed
12
+ - [update_milestone] Fix issue where a due date was required to close a milestone [[#24](https://github.com/ManageIQ/multi_repo/pull/24)]
13
+ - [GitHub service] Use newer method for actions-secrets creation [[#27](https://github.com/ManageIQ/multi_repo/pull/27)]
14
+
15
+ ## [0.3.1] - 2024-01-31
16
+ ### Fixed
17
+ - [pull_request_blaster_outer] Various fixes and cleanup output [[#21](https://github.com/ManageIQ/multi_repo/pull/21)]
18
+ - [show_commit_history] Prevent missing ranges from failing the entire run [[#20](https://github.com/ManageIQ/multi_repo/pull/20)]
19
+ - [pull_request_merger] Fixing issue passing kwargs on Ruby 3 [[#23](https://github.com/ManageIQ/multi_repo/pull/23)]
20
+
21
+ [Unreleased]: https://github.com/ManageIQ/more_core_extensions/compare/v0.4.0...HEAD
22
+ [0.4.0]: https://github.com/ManageIQ/more_core_extensions/compare/v0.3.1...v0.4.0
23
+ [0.3.1]: https://github.com/ManageIQ/more_core_extensions/compare/v0.3.0...v0.3.1
@@ -9,8 +9,7 @@ module MultiRepo::Helpers
9
9
  @base = base
10
10
  @head = head
11
11
  @script = begin
12
- s = Pathname.new(script)
13
- s = Pathname.new(Dir.pwd).join(script) if s.relative?
12
+ s = Pathname.new(script).expand_path
14
13
  raise "File not found #{s}" unless s.exist?
15
14
  s.to_s
16
15
  end
@@ -20,12 +19,10 @@ module MultiRepo::Helpers
20
19
  end
21
20
 
22
21
  def blast
23
- puts "+++ blasting #{repo.name}..."
24
-
25
22
  repo.git.fetch
26
23
 
27
24
  unless repo.git.remote_branch?("origin", base)
28
- puts "!!! Skipping #{repo.name}: 'origin/#{base}' not found"
25
+ puts "!! Skipping #{repo.name}: 'origin/#{base}' not found".light_yellow
29
26
  return
30
27
  end
31
28
 
@@ -33,20 +30,31 @@ module MultiRepo::Helpers
33
30
  run_script
34
31
 
35
32
  result = false
36
- if !commit_changes
37
- puts "!!! Failed to commit changes. Perhaps the script is wrong or #{repo.name} is already updated."
38
- elsif dry_run
39
- result = "Committed but is dry run"
33
+ if !changes_found?
34
+ puts
35
+ puts "!! Skipping #{repo.name}: No changes found".light_yellow
36
+ result = "no changes".light_yellow
40
37
  else
41
- puts "Do you want to open a pull request on #{repo.name} with the above changes? (Y/N)"
42
- answer = $stdin.gets.chomp
43
- if answer.upcase.start_with?("Y")
44
- fork_repo unless forked?
45
- push_branch
46
- result = open_pull_request
38
+ commit_changes
39
+ show_commit
40
+ puts
41
+
42
+ if dry_run
43
+ puts "** dry-run: Skipping opening pull request".light_black
44
+ result = "dry run".light_black
45
+ else
46
+ print "Do you want to open a pull request on #{repo.name} with the above changes? (y/N): "
47
+ answer = $stdin.gets.chomp
48
+ if answer.upcase.start_with?("Y")
49
+ fork_repo unless forked?
50
+ push_branch
51
+ result = open_pull_request
52
+ else
53
+ puts "!! Skipping #{repo.name}: User ignored".light_yellow
54
+ result = "ignored".light_yellow
55
+ end
47
56
  end
48
57
  end
49
- puts "--- blasting #{repo.name} complete"
50
58
  result
51
59
  end
52
60
 
@@ -57,7 +65,9 @@ module MultiRepo::Helpers
57
65
  end
58
66
 
59
67
  def forked?
60
- github.client.repos(github.client.login).any? { |m| m.name == repo.name }
68
+ # NOTE: There is an assumption here that the fork's name will match the source's name.
69
+ # Ideally there would be a "forked from" field in the repo metadata, but there isn't.
70
+ github.client.repos(github.client.login, :type => "forks").any? { |m| m.name == repo.short_name }
61
71
  end
62
72
 
63
73
  def fork_repo
@@ -70,41 +80,41 @@ module MultiRepo::Helpers
70
80
 
71
81
  def run_script
72
82
  repo.chdir do
73
- parts = []
74
- parts << "GITHUB_REPO=#{repo.name}"
75
- parts << "DRY_RUN=true" if dry_run
76
- parts << script
77
- cmd = parts.join(" ")
78
-
79
- unless system(cmd)
80
- puts "!!! Script execution failed."
81
- exit $?.exitstatus
83
+ Bundler.with_unbundled_env do
84
+ parts = []
85
+ parts << "GITHUB_REPO=#{repo.name}"
86
+ parts << "DRY_RUN=true" if dry_run
87
+ parts << script
88
+ cmd = parts.join(" ")
89
+
90
+ unless system(cmd)
91
+ puts "!! Script execution failed.".light_red
92
+ exit $?.exitstatus
93
+ end
82
94
  end
83
95
  end
84
96
  end
85
97
 
98
+ def changes_found?
99
+ repo.git.client.capturing.status("--porcelain").chomp.present?
100
+ end
101
+
86
102
  def commit_changes
87
- repo.chdir do
88
- begin
89
- repo.git.client.add("-v", ".")
90
- repo.git.client.commit("-m", message)
91
- repo.git.client.show
92
- if dry_run
93
- puts "!!! --dry-run enabled: If the above commit in #{repo.path} looks good, run again without dry run to fork the repo, push the branch and open a pull request."
94
- end
95
- true
96
- rescue MiniGit::GitError => e
97
- e.status.exitstatus == 0
98
- end
99
- end
103
+ repo.git.client.add("-v", ".")
104
+ repo.git.client.commit("-m", message)
105
+ end
106
+
107
+ def show_commit
108
+ repo.git.client.show
100
109
  end
101
110
 
102
- def origin_remote
111
+ def blast_remote
103
112
  "pr_blaster_outer"
104
113
  end
105
114
 
106
- def origin_url
107
- "git@github.com:#{github.client.login}/#{repo.name}.git"
115
+ def blast_remote_url
116
+ # NOTE: Similar to `forked?`, there is an assumption here that the fork's name will match the source's name.
117
+ "git@github.com:#{github.client.login}/#{repo.short_name}.git"
108
118
  end
109
119
 
110
120
  def pr_head
@@ -112,10 +122,8 @@ module MultiRepo::Helpers
112
122
  end
113
123
 
114
124
  def push_branch
115
- repo.chdir do
116
- repo.git.client.remote("add", origin_remote, origin_url) unless repo.git.remote?(origin_remote)
117
- repo.git.client.push("-f", origin_remote, "#{head}:#{head}")
118
- end
125
+ repo.git.client.remote("add", blast_remote, blast_remote_url) unless repo.git.remote?(blast_remote)
126
+ repo.git.client.push("-f", blast_remote, "#{head}:#{head}")
119
127
  end
120
128
 
121
129
  def open_pull_request
@@ -123,7 +131,7 @@ module MultiRepo::Helpers
123
131
  pr.html_url
124
132
  rescue => err
125
133
  raise unless err.message.include?("A pull request already exists")
126
- puts "!!! Skipping. #{err.message}"
134
+ puts "!! Skipping #{repo.name}: #{err.message}".light_yellow
127
135
  end
128
136
  end
129
137
  end
@@ -1,5 +1,3 @@
1
-
2
-
3
1
  module MultiRepo::Helpers
4
2
  class UpdateMilestone
5
3
  attr_reader :repo_name, :title, :due_on, :close, :github
@@ -15,15 +13,19 @@ module MultiRepo::Helpers
15
13
  end
16
14
 
17
15
  def run
18
- due_on_str = due_on.strftime("%Y-%m-%d").inspect
19
-
20
16
  existing = github.find_milestone_by_title(repo_name, title)
17
+
21
18
  if close
22
19
  if existing
23
20
  puts "Closing milestone #{title.inspect} (#{existing.number})"
24
- github.close_milestone(repo_name, title, existing.number)
21
+ github.close_milestone(repo_name, existing.number)
25
22
  end
26
- elsif existing
23
+ return
24
+ end
25
+
26
+ due_on_str = due_on.strftime("%Y-%m-%d").inspect
27
+
28
+ if existing
27
29
  puts "Updating milestone #{title.inspect} (#{existing.number}) with due date #{due_on_str}"
28
30
  github.update_milestone(repo_name, existing.number, due_on)
29
31
  else
@@ -5,11 +5,11 @@ module MultiRepo
5
5
  attr_reader :name, :config, :path
6
6
  attr_accessor :dry_run
7
7
 
8
- def initialize(name, config: nil, dry_run: false)
8
+ def initialize(name, path: nil, config: nil, dry_run: false)
9
9
  @name = name
10
10
  @dry_run = dry_run
11
11
  @config = OpenStruct.new(config || {})
12
- @path = MultiRepo.repos_dir.join(name)
12
+ @path = path || MultiRepo.repos_dir.join(name)
13
13
  end
14
14
 
15
15
  alias to_s inspect
@@ -212,17 +212,19 @@ module MultiRepo::Service
212
212
  payload = encode_secret(repo_name, value)
213
213
 
214
214
  if dry_run
215
- puts "** dry-run: github.create_or_update_secret(#{repo_name.inspect}, #{key.inspect}, #{payload.inspect})".light_black
215
+ puts "** dry-run: github.create_or_update_actions_secret(#{repo_name.inspect}, #{key.inspect}, #{payload.inspect})".light_black
216
216
  else
217
- client.create_or_update_secret(repo_name, key, payload)
217
+ client.create_or_update_actions_secret(repo_name, key, payload)
218
218
  end
219
219
  end
220
220
 
221
221
  private def encode_secret(repo_name, value)
222
+ raise ArgumentError, "value to encode cannot be nil" if value.nil?
223
+
222
224
  require "rbnacl"
223
225
  require "base64"
224
226
 
225
- repo_public_key = client.get_public_key(repo_name)
227
+ repo_public_key = client.get_actions_public_key(repo_name)
226
228
  decoded_repo_public_key = Base64.decode64(repo_public_key.key)
227
229
  public_key = RbNaCl::PublicKey.new(decoded_repo_public_key)
228
230
  box = RbNaCl::Boxes::Sealed.from_public_key(public_key)
@@ -1,3 +1,3 @@
1
1
  module MultiRepo
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0".freeze
3
3
  end
data/multi_repo.gemspec CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
28
28
  spec.add_runtime_dependency "licensee"
29
29
  spec.add_runtime_dependency "minigit"
30
30
  spec.add_runtime_dependency "more_core_extensions"
31
- spec.add_runtime_dependency "octokit", ">=4.23.0"
31
+ spec.add_runtime_dependency "octokit", ">= 7.0.0"
32
32
  spec.add_runtime_dependency "optimist"
33
33
  spec.add_runtime_dependency "progressbar"
34
34
  spec.add_runtime_dependency "psych", ">=3"
data/renovate.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
+ "extends": [
4
+ "config:recommended"
5
+ ]
6
+ }
@@ -4,7 +4,9 @@ require "bundler/inline"
4
4
  gemfile do
5
5
  source "https://rubygems.org"
6
6
  gem "multi_repo", require: "multi_repo/cli", path: File.expand_path("..", __dir__)
7
+ gem "more_core_extensions"
7
8
  end
9
+ require "more_core_extensions/core_ext/array/tableize"
8
10
 
9
11
  opts = Optimist.options do
10
12
  synopsis "Create a pull request on all repos."
@@ -19,8 +21,11 @@ opts = Optimist.options do
19
21
  end
20
22
 
21
23
  results = {}
22
- MultiRepo::CLI.each_repo(**opts) do |repo|
23
- results[repo.name] = MultiRepo::Helpers::PullRequestBlasterOuter.new(repo, **opts).blast
24
+ begin
25
+ MultiRepo::CLI.each_repo(**opts) do |repo|
26
+ results[repo.name] = MultiRepo::Helpers::PullRequestBlasterOuter.new(repo, **opts).blast
27
+ end
28
+ ensure
29
+ puts "Summary:"
30
+ puts results.to_a.tableize(:header => false) unless results.empty?
24
31
  end
25
-
26
- pp results
@@ -57,9 +57,9 @@ opts[:prs].each do |pr|
57
57
 
58
58
  repo_name, pr_number = PR_REGEX.match(pr).captures
59
59
 
60
- merge_pull_request(repo_name, pr_number, opts)
61
- add_labels(repo_name, pr_number, opts) if opts[:labels].present?
62
- assign_user(repo_name, pr_number, opts)
60
+ merge_pull_request(repo_name, pr_number, **opts)
61
+ add_labels(repo_name, pr_number, **opts) if opts[:labels].present?
62
+ assign_user(repo_name, pr_number, **opts)
63
63
 
64
64
  puts
65
65
  end
@@ -48,7 +48,15 @@ MultiRepo::CLI.repos_for(**opts).each do |repo|
48
48
  end
49
49
  results["other"] = []
50
50
 
51
- log = repo.git.client.capturing.log({:oneline => true}, range)
51
+ log =
52
+ begin
53
+ repo.git.client.capturing.log({:oneline => true}, range)
54
+ rescue MiniGit::GitError
55
+ puts "ERROR: commit range not found.".light_red
56
+ puts
57
+ next
58
+ end
59
+
52
60
  log.lines.each do |line|
53
61
  next unless (match = line.match(/Merge pull request #(\d+)\b/))
54
62
 
@@ -71,7 +79,15 @@ MultiRepo::CLI.repos_for(**opts).each do |repo|
71
79
 
72
80
  repos_with_changes << repo if changes_found
73
81
  when "commit"
74
- output = repo.git.client.capturing.log({:oneline => true, :decorate => true, :graph => true}, range)
82
+ output =
83
+ begin
84
+ repo.git.client.capturing.log({:oneline => true, :decorate => true, :graph => true}, range)
85
+ rescue MiniGit::GitError
86
+ puts "ERROR: commit range not found.".light_red
87
+ puts
88
+ next
89
+ end
90
+
75
91
  puts output
76
92
  repos_with_changes << repo if output.present?
77
93
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multi_repo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ManageIQ Authors
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-08-07 00:00:00.000000000 Z
11
+ date: 2024-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - ">="
102
102
  - !ruby/object:Gem::Version
103
- version: 4.23.0
103
+ version: 7.0.0
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
- version: 4.23.0
110
+ version: 7.0.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: optimist
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -279,6 +279,7 @@ files:
279
279
  - ".rubocop_cc.yml"
280
280
  - ".rubocop_local.yml"
281
281
  - ".whitesource"
282
+ - CHANGELOG.md
282
283
  - Gemfile
283
284
  - LICENSE.txt
284
285
  - README.md
@@ -309,6 +310,7 @@ files:
309
310
  - lib/multi_repo/service/travis.rb
310
311
  - lib/multi_repo/version.rb
311
312
  - multi_repo.gemspec
313
+ - renovate.json
312
314
  - repos/.gitkeep
313
315
  - scripts/delete_labels
314
316
  - scripts/destroy_branch
@@ -358,7 +360,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
358
360
  - !ruby/object:Gem::Version
359
361
  version: '0'
360
362
  requirements: []
361
- rubygems_version: 3.2.33
363
+ rubygems_version: 3.3.26
362
364
  signing_key:
363
365
  specification_version: 4
364
366
  summary: MultiRepo is a library for managing multiple repositiories and running scripts