multi_repo 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yaml +13 -12
- data/CHANGELOG.md +18 -2
- data/README.md +2 -3
- data/lib/multi_repo/helpers/pull_request_blaster_outer.rb +32 -9
- data/lib/multi_repo/repo.rb +8 -0
- data/lib/multi_repo/service/artifactory.rb +14 -0
- data/lib/multi_repo/service/git.rb +1 -1
- data/lib/multi_repo/service/github.rb +6 -0
- data/lib/multi_repo/version.rb +1 -1
- data/lib/multi_repo.rb +0 -1
- data/multi_repo.gemspec +1 -1
- data/scripts/delete_labels +1 -1
- data/scripts/each_repo +4 -2
- data/scripts/pull_request_blaster_outer +16 -4
- data/scripts/show_commit_history +1 -1
- data/scripts/show_org_repos +4 -1
- metadata +4 -7
- data/.codeclimate.yml +0 -16
- data/.rubocop_cc.yml +0 -4
- data/lib/multi_repo/service/code_climate.rb +0 -119
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ff97c5d89d0a12946bcfeedc113427407e9858f72f687cad2c6c133db1bb41b4
|
|
4
|
+
data.tar.gz: 12f0b8884470a4dd1430cdc1b4bb131f3f93e5957bf66c5400ffa67d3fdbce78
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e562d3f593d9b5f3481cc8d1aafdc67aa0c938bd266f2ab939d07ebdd8fde31dbebf26026760451fcb0127613f0f356bf9f03ee7d264851f8b77d0747882f385
|
|
7
|
+
data.tar.gz: 03b147b28464d5179423794d5e96ee42feb3b8edc586d0407d9560769ba42ece76d498090692bebac3d339948defd498fe9e2820fc8e39dc24b8318fa512f6f8
|
data/.github/workflows/ci.yaml
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
name: CI
|
|
2
|
-
|
|
3
2
|
on:
|
|
4
|
-
push:
|
|
5
3
|
pull_request:
|
|
4
|
+
push:
|
|
5
|
+
branches-ignore:
|
|
6
|
+
- dependabot/*
|
|
7
|
+
- renovate/*
|
|
6
8
|
schedule:
|
|
7
|
-
- cron:
|
|
8
|
-
|
|
9
|
+
- cron: 0 0 * * 0
|
|
10
|
+
workflow_dispatch:
|
|
11
|
+
concurrency:
|
|
12
|
+
group: "${{ github.workflow }}-${{ github.ref }}"
|
|
13
|
+
cancel-in-progress: true
|
|
14
|
+
permissions:
|
|
15
|
+
contents: read
|
|
9
16
|
jobs:
|
|
10
17
|
ci:
|
|
11
18
|
runs-on: ubuntu-latest
|
|
@@ -16,19 +23,13 @@ jobs:
|
|
|
16
23
|
- '3.1'
|
|
17
24
|
- '3.2'
|
|
18
25
|
- '3.3'
|
|
19
|
-
env:
|
|
20
|
-
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
|
|
21
26
|
steps:
|
|
22
|
-
- uses: actions/checkout@
|
|
27
|
+
- uses: actions/checkout@v6
|
|
23
28
|
- name: Set up Ruby
|
|
24
29
|
uses: ruby/setup-ruby@v1
|
|
25
30
|
with:
|
|
26
|
-
ruby-version: ${{ matrix.ruby-version }}
|
|
31
|
+
ruby-version: "${{ matrix.ruby-version }}"
|
|
27
32
|
bundler-cache: true
|
|
28
33
|
timeout-minutes: 30
|
|
29
34
|
- name: Run tests
|
|
30
35
|
run: bundle exec rake
|
|
31
|
-
- name: Report code coverage
|
|
32
|
-
if: ${{ github.ref == 'refs/heads/master' && matrix.ruby-version == '3.1' }}
|
|
33
|
-
continue-on-error: true
|
|
34
|
-
uses: paambaati/codeclimate-action@v9
|
data/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,21 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [1.2.0] - 2026-04-14
|
|
8
|
+
### Added
|
|
9
|
+
- [Artifactory service] Add head and exists? methods [[#97](https://github.com/ManageIQ/multi_repo/pull/97)]
|
|
10
|
+
- [pull_request_blaster_outer] Add ability to override message in the script [[#70](https://github.com/ManageIQ/multi_repo/pull/70)]
|
|
11
|
+
- [pull_request_blaster_outer] Add ability to specify a different fork name [[#71](https://github.com/ManageIQ/multi_repo/pull/71)]
|
|
12
|
+
- [show_org_repos] Add options include_forks and include_archived [[#73](https://github.com/ManageIQ/multi_repo/pull/73)]
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
- [Git service] Handle when tags move during a git fetch which would otherwise fail [[#75](https://github.com/ManageIQ/multi_repo/pull/75)]
|
|
16
|
+
- [each_repo] Fix each_repo when the script needs to bundle [[#72](https://github.com/ManageIQ/multi_repo/pull/72)]
|
|
17
|
+
- [delete_labels] Fix a constant problem [[#67](https://github.com/ManageIQ/multi_repo/pull/67)]
|
|
18
|
+
|
|
19
|
+
### Removed
|
|
20
|
+
- **BREAKING** Drop CodeClimate [[#74](https://github.com/ManageIQ/multi_repo/pull/74)]
|
|
21
|
+
|
|
7
22
|
## [1.1.0] - 2025-10-01
|
|
8
23
|
### Added
|
|
9
24
|
- [show_commit_history] Add pr-changelog display format [[#49](https://github.com/ManageIQ/multi_repo/pull/49)]
|
|
@@ -44,7 +59,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
|
44
59
|
|
|
45
60
|
### Fixed
|
|
46
61
|
- [pull_request_labeler] Fix cli description of --prs [[#30](https://github.com/ManageIQ/multi_repo/pull/30)]
|
|
47
|
-
- [show_commit_history] Handle issue where PR may not be found [[#36](https://github.com/ManageIQ/multi_repo/pull/
|
|
62
|
+
- [show_commit_history] Handle issue where PR may not be found [[#36](https://github.com/ManageIQ/multi_repo/pull/36)]
|
|
48
63
|
|
|
49
64
|
## [0.4.0] - 2024-03-29
|
|
50
65
|
### Changed
|
|
@@ -60,7 +75,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
|
60
75
|
- [show_commit_history] Prevent missing ranges from failing the entire run [[#20](https://github.com/ManageIQ/multi_repo/pull/20)]
|
|
61
76
|
- [pull_request_merger] Fixing issue passing kwargs on Ruby 3 [[#23](https://github.com/ManageIQ/multi_repo/pull/23)]
|
|
62
77
|
|
|
63
|
-
[Unreleased]: https://github.com/ManageIQ/multi_repo/compare/v1.
|
|
78
|
+
[Unreleased]: https://github.com/ManageIQ/multi_repo/compare/v1.2.0...HEAD
|
|
79
|
+
[1.2.0]: https://github.com/ManageIQ/multi_repo/compare/v1.1.0...v1.2.0
|
|
64
80
|
[1.1.0]: https://github.com/ManageIQ/multi_repo/compare/v1.0.0...v1.1.0
|
|
65
81
|
[1.0.0]: https://github.com/ManageIQ/multi_repo/compare/v0.6.0...v1.0.0
|
|
66
82
|
[0.6.0]: https://github.com/ManageIQ/multi_repo/compare/v0.5.1...v0.6.0
|
data/README.md
CHANGED
|
@@ -4,7 +4,6 @@ MultiRepo is a tool for managing multiple git repositories.
|
|
|
4
4
|
|
|
5
5
|
[](http://badge.fury.io/rb/multi_repo)
|
|
6
6
|
[](https://github.com/ManageIQ/multi_repo/actions/workflows/ci.yaml)
|
|
7
|
-
[](https://codeclimate.com/github/ManageIQ/multi_repo)
|
|
8
7
|
|
|
9
8
|
## Installation
|
|
10
9
|
|
|
@@ -19,7 +18,7 @@ gem install multi_repo
|
|
|
19
18
|
Typical usage will be from single scripts. In order to keep each script manageable, it can be preferable to use bundler/inline to define the gems needed by that script. To do this, add the following to the top of the script:
|
|
20
19
|
|
|
21
20
|
```ruby
|
|
22
|
-
|
|
21
|
+
#!/usr/bin/env ruby
|
|
23
22
|
|
|
24
23
|
require "bundler/inline"
|
|
25
24
|
gemfile do
|
|
@@ -69,7 +68,7 @@ purposes
|
|
|
69
68
|
- Go to https://github.com/settings/tokens
|
|
70
69
|
- Choose "Generate New Token"
|
|
71
70
|
- Give the token a description
|
|
72
|
-
- At a
|
|
71
|
+
- At a minimum, choose "repo" for the permissions.
|
|
73
72
|
- Click "Generate Token"
|
|
74
73
|
- Copy the token given to you, and keep it in a safe location, as once you leave
|
|
75
74
|
the page, the token is no longer accessible
|
|
@@ -2,7 +2,7 @@ require 'pathname'
|
|
|
2
2
|
|
|
3
3
|
module MultiRepo::Helpers
|
|
4
4
|
class PullRequestBlasterOuter
|
|
5
|
-
attr_reader :repo, :base, :head, :script, :dry_run, :
|
|
5
|
+
attr_reader :repo, :base, :head, :script, :dry_run, :source_message, :source_title, :source_body, :force
|
|
6
6
|
|
|
7
7
|
def initialize(repo, base:, head:, script:, dry_run:, message:, title: nil, body: nil, force: false, **)
|
|
8
8
|
@repo = repo
|
|
@@ -14,10 +14,11 @@ module MultiRepo::Helpers
|
|
|
14
14
|
s.to_s
|
|
15
15
|
end
|
|
16
16
|
@dry_run = dry_run
|
|
17
|
-
@message = message
|
|
18
|
-
@title = (title || message)[0, 72]
|
|
19
|
-
@body = (body || message).gsub("\\n", "\n")
|
|
20
17
|
@force = force
|
|
18
|
+
|
|
19
|
+
@source_message = message&.gsub("\\n", "\n")
|
|
20
|
+
@source_title = title
|
|
21
|
+
@source_body = body&.gsub("\\n", "\n")
|
|
21
22
|
end
|
|
22
23
|
|
|
23
24
|
def blast
|
|
@@ -44,8 +45,10 @@ module MultiRepo::Helpers
|
|
|
44
45
|
if dry_run
|
|
45
46
|
puts "** dry-run: Skipping opening pull request. The pull request would look like:".light_black
|
|
46
47
|
puts
|
|
48
|
+
puts "Pull Request Title:".light_black
|
|
47
49
|
puts title.light_black
|
|
48
50
|
puts
|
|
51
|
+
puts "Pull Request Body:".light_black
|
|
49
52
|
puts body.light_black
|
|
50
53
|
|
|
51
54
|
result = "dry run".light_black
|
|
@@ -73,19 +76,31 @@ module MultiRepo::Helpers
|
|
|
73
76
|
|
|
74
77
|
private
|
|
75
78
|
|
|
79
|
+
attr_accessor :override_message
|
|
80
|
+
|
|
81
|
+
def message
|
|
82
|
+
override_message || source_message
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def title
|
|
86
|
+
source_title || message.lines.first.chomp[0, 72]
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def body
|
|
90
|
+
source_body || message.lines.drop(1).join.strip
|
|
91
|
+
end
|
|
92
|
+
|
|
76
93
|
def github
|
|
77
94
|
@github ||= MultiRepo::Service::Github.new(dry_run: dry_run)
|
|
78
95
|
end
|
|
79
96
|
|
|
80
|
-
def forked?
|
|
81
|
-
|
|
82
|
-
# Ideally there would be a "forked from" field in the repo metadata, but there isn't.
|
|
83
|
-
github.client.repos(github.client.login, :type => "forks").any? { |m| m.name == repo.short_name }
|
|
97
|
+
def forked?(cache: true)
|
|
98
|
+
github.forks(cache: cache).any? { |f| f.name == repo.fork_short_name }
|
|
84
99
|
end
|
|
85
100
|
|
|
86
101
|
def fork_repo
|
|
87
102
|
github.client.fork(repo.name)
|
|
88
|
-
until forked?
|
|
103
|
+
until forked?(cache: false)
|
|
89
104
|
print "."
|
|
90
105
|
sleep 3
|
|
91
106
|
end
|
|
@@ -94,6 +109,10 @@ module MultiRepo::Helpers
|
|
|
94
109
|
def run_script
|
|
95
110
|
repo.chdir do
|
|
96
111
|
Bundler.with_unbundled_env do
|
|
112
|
+
# Ensure any previous override commit message is removed
|
|
113
|
+
FileUtils.rm_f(".git/COMMIT_EDITMSG")
|
|
114
|
+
self.override_message = nil
|
|
115
|
+
|
|
97
116
|
parts = []
|
|
98
117
|
parts << "GITHUB_REPO=#{repo.name}"
|
|
99
118
|
parts << "DRY_RUN=true" if dry_run
|
|
@@ -104,6 +123,10 @@ module MultiRepo::Helpers
|
|
|
104
123
|
puts "!! Script execution failed.".light_red
|
|
105
124
|
exit $?.exitstatus
|
|
106
125
|
end
|
|
126
|
+
|
|
127
|
+
if File.exist?(".git/COMMIT_EDITMSG")
|
|
128
|
+
self.override_message = File.read(".git/COMMIT_EDITMSG")
|
|
129
|
+
end
|
|
107
130
|
end
|
|
108
131
|
end
|
|
109
132
|
end
|
data/lib/multi_repo/repo.rb
CHANGED
|
@@ -27,6 +27,14 @@ module MultiRepo
|
|
|
27
27
|
name.split("/").last
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
+
def fork_name
|
|
31
|
+
config.fork_name
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def fork_short_name
|
|
35
|
+
fork_name&.split("/")&.last || short_name
|
|
36
|
+
end
|
|
37
|
+
|
|
30
38
|
def write_file(file, content, **kwargs)
|
|
31
39
|
if dry_run
|
|
32
40
|
puts "** dry-run: Writing #{path.join(file).expand_path}".light_black
|
|
@@ -40,6 +40,18 @@ module MultiRepo::Service
|
|
|
40
40
|
request(:get, path, **kwargs)
|
|
41
41
|
end
|
|
42
42
|
|
|
43
|
+
def head(path, **kwargs)
|
|
44
|
+
path = path.to_s
|
|
45
|
+
request(:head, path, **kwargs)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def exists?(path, **kwargs)
|
|
49
|
+
head(path, **kwargs)
|
|
50
|
+
true
|
|
51
|
+
rescue RestClient::NotFound
|
|
52
|
+
false
|
|
53
|
+
end
|
|
54
|
+
|
|
43
55
|
def list(folder, cache: @cache, **kwargs)
|
|
44
56
|
folder = folder.to_s
|
|
45
57
|
cache_file = "/tmp/artifactory-#{folder.tr("/", "_")}-#{Date.today}.txt"
|
|
@@ -94,6 +106,8 @@ module MultiRepo::Service
|
|
|
94
106
|
"Accept" => "application/json",
|
|
95
107
|
"Content-Type" => "application/json"
|
|
96
108
|
)
|
|
109
|
+
headers = headers.except("Accept") if verb == :head
|
|
110
|
+
|
|
97
111
|
path = File.join(self.class.api_endpoint, path)
|
|
98
112
|
|
|
99
113
|
puts "+ #{verb.to_s.upcase} #{path}".light_black if verbose
|
|
@@ -49,7 +49,7 @@ module MultiRepo::Service
|
|
|
49
49
|
def fetch(output: false)
|
|
50
50
|
client = output ? self.client : self.client.capturing
|
|
51
51
|
|
|
52
|
-
client.fetch(:all => true, :tags => true)
|
|
52
|
+
client.fetch(:all => true, :tags => true, :force => true)
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
def hard_checkout(branch, source = "origin/#{branch}", output: false)
|
|
@@ -90,6 +90,11 @@ module MultiRepo::Service
|
|
|
90
90
|
client.workflows(repo_name)[:workflows].select { |w| w.state == "disabled_inactivity" }
|
|
91
91
|
end
|
|
92
92
|
|
|
93
|
+
def self.forks(cache: true)
|
|
94
|
+
@forks = nil unless cache
|
|
95
|
+
@forks ||= client.repos(client.login, :type => "forks")
|
|
96
|
+
end
|
|
97
|
+
|
|
93
98
|
PR_REGEX = %r{^([^/#]+/[^/#]+)#(\d+)$}
|
|
94
99
|
|
|
95
100
|
# Parse a list of PRs that are in URL or org/repo#pr format into a Array of
|
|
@@ -125,6 +130,7 @@ module MultiRepo::Service
|
|
|
125
130
|
:team_member_names,
|
|
126
131
|
:team_ids_by_name,
|
|
127
132
|
:team_names,
|
|
133
|
+
:forks,
|
|
128
134
|
:disabled_workflows,
|
|
129
135
|
:to => :class
|
|
130
136
|
|
data/lib/multi_repo/version.rb
CHANGED
data/lib/multi_repo.rb
CHANGED
|
@@ -11,7 +11,6 @@ require 'multi_repo/repo'
|
|
|
11
11
|
require 'multi_repo/repo_set'
|
|
12
12
|
|
|
13
13
|
require 'multi_repo/service/artifactory'
|
|
14
|
-
require 'multi_repo/service/code_climate'
|
|
15
14
|
require 'multi_repo/service/docker'
|
|
16
15
|
require 'multi_repo/service/git'
|
|
17
16
|
require 'multi_repo/service/github'
|
data/multi_repo.gemspec
CHANGED
|
@@ -36,7 +36,7 @@ Gem::Specification.new do |spec|
|
|
|
36
36
|
spec.add_runtime_dependency "rest-client"
|
|
37
37
|
|
|
38
38
|
spec.add_development_dependency "bundler"
|
|
39
|
-
spec.add_development_dependency "manageiq-style"
|
|
39
|
+
spec.add_development_dependency "manageiq-style"
|
|
40
40
|
spec.add_development_dependency "rake"
|
|
41
41
|
spec.add_development_dependency "rspec", ">= 3.0"
|
|
42
42
|
spec.add_development_dependency "simplecov", ">= 0.21.2"
|
data/scripts/delete_labels
CHANGED
|
@@ -13,7 +13,7 @@ opts = Optimist.options do
|
|
|
13
13
|
|
|
14
14
|
MultiRepo::CLI.common_options(self, :repo_set_default => nil)
|
|
15
15
|
end
|
|
16
|
-
opts[:repo] = MultiRepo::
|
|
16
|
+
opts[:repo] = MultiRepo::Labels.all.keys.sort unless opts[:repo] || opts[:repo_set]
|
|
17
17
|
|
|
18
18
|
github = MultiRepo::Service::Github.new(dry_run: opts[:dry_run])
|
|
19
19
|
|
data/scripts/each_repo
CHANGED
|
@@ -19,7 +19,9 @@ MultiRepo::CLI.each_repo(**opts) do |repo|
|
|
|
19
19
|
repo.git.fetch
|
|
20
20
|
repo.git.hard_checkout(opts[:ref])
|
|
21
21
|
repo.chdir do
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
Bundler.with_unbundled_env do
|
|
23
|
+
puts "+ #{opts[:command]}".light_black
|
|
24
|
+
system(opts[:command])
|
|
25
|
+
end
|
|
24
26
|
end
|
|
25
27
|
end
|
|
@@ -14,13 +14,25 @@ opts = Optimist.options do
|
|
|
14
14
|
opt :base, "The target branch for the changes.", :type => :string, :required => true
|
|
15
15
|
opt :head, "The name of the branch to create on your fork.", :type => :string, :required => true
|
|
16
16
|
opt :script, "The path to the script that will update the desired files.", :type => :string, :required => true
|
|
17
|
-
opt :
|
|
18
|
-
opt :title, "The PR title for this change. (default is --message)", :type => :string
|
|
19
|
-
opt :body, "The PR body for this change. (default is --message)", :type => :string
|
|
17
|
+
opt :force, "Force creation of the pull request without asking.", :default => false
|
|
20
18
|
|
|
21
|
-
|
|
19
|
+
see_below = "See \"Notes on commit messages\" section below."
|
|
20
|
+
opt :message, "The commit message for this change. #{see_below}", :type => :string, :required => true
|
|
21
|
+
opt :title, "The PR title for this change. #{see_below}", :type => :string
|
|
22
|
+
opt :body, "The PR body for this change. #{see_below}", :type => :string
|
|
22
23
|
|
|
23
24
|
MultiRepo::CLI.common_options(self)
|
|
25
|
+
opt :help, "Show this message" # Ensure help appears above the notes sections
|
|
26
|
+
|
|
27
|
+
banner ""
|
|
28
|
+
banner <<~EOS
|
|
29
|
+
Notes on commit messages:
|
|
30
|
+
* The --message and --body options can accept '\\n' characters to support multiline messages.
|
|
31
|
+
* In a script, you can override --message by writing the commit message contents to .git/COMMIT_EDITMSG.
|
|
32
|
+
* The --title will default to the first line of the message.
|
|
33
|
+
* The --body will default to the rest of the message.
|
|
34
|
+
* If you want to override the title or body, you can do so with the --title and --body options, respectively.
|
|
35
|
+
EOS
|
|
24
36
|
end
|
|
25
37
|
|
|
26
38
|
results = {}
|
data/scripts/show_commit_history
CHANGED
|
@@ -15,7 +15,7 @@ opts = Optimist.options do
|
|
|
15
15
|
synopsis "Show the git commit log between two refs for all git repos."
|
|
16
16
|
|
|
17
17
|
opt :from, "The commit log 'from' ref", :type => :string, :required => true
|
|
18
|
-
opt :to, "The commit log 'to' ref"
|
|
18
|
+
opt :to, "The commit log 'to' ref", :type => :string, :required => true
|
|
19
19
|
opt :display, "How to display the history. Valid values are: #{DISPLAY_FORMATS.join(", ")}", :default => "commit"
|
|
20
20
|
opt :summary, "Display a summary of the repos.", :default => false
|
|
21
21
|
|
data/scripts/show_org_repos
CHANGED
|
@@ -10,6 +10,9 @@ opts = Optimist.options do
|
|
|
10
10
|
synopsis "List all repos in an org."
|
|
11
11
|
|
|
12
12
|
opt :org, "The org to list the repos for", :type => :string, :required => true
|
|
13
|
+
|
|
14
|
+
opt :include_forks, "Include forked repos", :default => false
|
|
15
|
+
opt :include_archived, "Include archived repos", :default => false
|
|
13
16
|
end
|
|
14
17
|
|
|
15
|
-
puts MultiRepo::Service::Github.org_repo_names(opts[:org])
|
|
18
|
+
puts MultiRepo::Service::Github.org_repo_names(opts[:org], **opts.slice(:include_forks, :include_archived))
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: multi_repo
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- ManageIQ Authors
|
|
@@ -197,14 +197,14 @@ dependencies:
|
|
|
197
197
|
requirements:
|
|
198
198
|
- - ">="
|
|
199
199
|
- !ruby/object:Gem::Version
|
|
200
|
-
version:
|
|
200
|
+
version: '0'
|
|
201
201
|
type: :development
|
|
202
202
|
prerelease: false
|
|
203
203
|
version_requirements: !ruby/object:Gem::Requirement
|
|
204
204
|
requirements:
|
|
205
205
|
- - ">="
|
|
206
206
|
- !ruby/object:Gem::Version
|
|
207
|
-
version:
|
|
207
|
+
version: '0'
|
|
208
208
|
- !ruby/object:Gem::Dependency
|
|
209
209
|
name: rake
|
|
210
210
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -256,12 +256,10 @@ executables:
|
|
|
256
256
|
extensions: []
|
|
257
257
|
extra_rdoc_files: []
|
|
258
258
|
files:
|
|
259
|
-
- ".codeclimate.yml"
|
|
260
259
|
- ".github/workflows/ci.yaml"
|
|
261
260
|
- ".gitignore"
|
|
262
261
|
- ".rspec"
|
|
263
262
|
- ".rubocop.yml"
|
|
264
|
-
- ".rubocop_cc.yml"
|
|
265
263
|
- ".rubocop_local.yml"
|
|
266
264
|
- ".whitesource"
|
|
267
265
|
- CHANGELOG.md
|
|
@@ -286,7 +284,6 @@ files:
|
|
|
286
284
|
- lib/multi_repo/repo.rb
|
|
287
285
|
- lib/multi_repo/repo_set.rb
|
|
288
286
|
- lib/multi_repo/service/artifactory.rb
|
|
289
|
-
- lib/multi_repo/service/code_climate.rb
|
|
290
287
|
- lib/multi_repo/service/docker.rb
|
|
291
288
|
- lib/multi_repo/service/git.rb
|
|
292
289
|
- lib/multi_repo/service/git/minigit_capturing_patch.rb
|
|
@@ -343,7 +340,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
343
340
|
- !ruby/object:Gem::Version
|
|
344
341
|
version: '0'
|
|
345
342
|
requirements: []
|
|
346
|
-
rubygems_version:
|
|
343
|
+
rubygems_version: 4.0.7
|
|
347
344
|
specification_version: 4
|
|
348
345
|
summary: MultiRepo is a library for managing multiple repositiories and running scripts
|
|
349
346
|
against them.
|
data/.codeclimate.yml
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
prepare:
|
|
2
|
-
fetch:
|
|
3
|
-
- url: https://raw.githubusercontent.com/ManageIQ/manageiq-style/master/.rubocop_base.yml
|
|
4
|
-
path: ".rubocop_base.yml"
|
|
5
|
-
- url: https://raw.githubusercontent.com/ManageIQ/manageiq-style/master/.rubocop_cc_base.yml
|
|
6
|
-
path: ".rubocop_cc_base.yml"
|
|
7
|
-
- url: https://raw.githubusercontent.com/ManageIQ/manageiq-style/master/styles/base.yml
|
|
8
|
-
path: styles/base.yml
|
|
9
|
-
- url: https://raw.githubusercontent.com/ManageIQ/manageiq-style/master/styles/cc_base.yml
|
|
10
|
-
path: styles/cc_base.yml
|
|
11
|
-
plugins:
|
|
12
|
-
rubocop:
|
|
13
|
-
enabled: true
|
|
14
|
-
config: ".rubocop_cc.yml"
|
|
15
|
-
channel: rubocop-1-56-3
|
|
16
|
-
version: '2'
|
data/.rubocop_cc.yml
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
module MultiRepo::Service
|
|
2
|
-
class CodeClimate
|
|
3
|
-
def self.api_token
|
|
4
|
-
@api_token ||= ENV["CODECLIMATE_API_TOKEN"]
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
def self.api_token=(token)
|
|
8
|
-
@api_token = token
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def self.badge_name
|
|
12
|
-
"Code Climate"
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def self.badge_details(repo)
|
|
16
|
-
{
|
|
17
|
-
"description" => badge_name,
|
|
18
|
-
"image" => "https://codeclimate.com/github/#{repo.name}.svg",
|
|
19
|
-
"url" => "https://codeclimate.com/github/#{repo.name}"
|
|
20
|
-
}
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def self.coverage_badge_name
|
|
24
|
-
"Test Coverage"
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def self.coverage_badge_details(repo)
|
|
28
|
-
{
|
|
29
|
-
"description" => coverage_badge_name,
|
|
30
|
-
"image" => "https://codeclimate.com/github/#{repo.name}/badges/coverage.svg",
|
|
31
|
-
"url" => "https://codeclimate.com/github/#{repo.name}/coverage"
|
|
32
|
-
}
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
attr_reader :repo, :dry_run
|
|
36
|
-
|
|
37
|
-
def initialize(repo, dry_run: false, **_)
|
|
38
|
-
@repo = repo
|
|
39
|
-
@dry_run = dry_run
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def save!
|
|
43
|
-
write_codeclimate_yaml
|
|
44
|
-
write_rubocop_yamls
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def enable
|
|
48
|
-
ensure_enabled
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def badge_details
|
|
52
|
-
self.class.badge_details(repo)
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def coverage_badge_details
|
|
56
|
-
self.class.coverage_badge_details(repo)
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def test_reporter_id
|
|
60
|
-
ensure_enabled
|
|
61
|
-
@response.dig("data", 0, "attributes", "test_reporter_id")
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
def create_repo_secret
|
|
65
|
-
Github.new(dry_run: dry_run).create_or_update_repository_secret(repo.name, "CC_TEST_REPORTER_ID", test_reporter_id)
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
private
|
|
69
|
-
|
|
70
|
-
def ensure_enabled
|
|
71
|
-
return if @enabled
|
|
72
|
-
|
|
73
|
-
require 'rest-client'
|
|
74
|
-
require 'json'
|
|
75
|
-
|
|
76
|
-
@response =
|
|
77
|
-
if dry_run
|
|
78
|
-
puts "** dry-run: RestClient.get(\"https://api.codeclimate.com/v1/repos?github_slug=#{repo.name}\", #{headers})".light_black
|
|
79
|
-
{"data" => [{"attributes" => {"badge_token" => "0123456789abdef01234", "test_reporter_id" => "0123456789abcedef0123456789abcedef0123456789abcedef0123456789abc"}}]}
|
|
80
|
-
else
|
|
81
|
-
JSON.parse(RestClient.get("https://api.codeclimate.com/v1/repos?github_slug=#{repo.name}", headers))
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
if @response["data"].empty?
|
|
85
|
-
payload = {"data" => {"type" => "repos", "attributes" => {"url" => "https://github.com/#{repo.name}"}}}.to_json
|
|
86
|
-
@response = JSON.parse(RestClient.post("https://api.codeclimate.com/v1/github/repos", payload, headers))
|
|
87
|
-
@response["data"] = [@response["data"]]
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
@enabled = true
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
def headers
|
|
94
|
-
token = self.class.api_token
|
|
95
|
-
raise "Missing CodeClimate API Token" if token.nil?
|
|
96
|
-
|
|
97
|
-
{
|
|
98
|
-
:accept => "application/vnd.api+json",
|
|
99
|
-
:content_type => "application/vnd.api+json",
|
|
100
|
-
:authorization => "Token token=#{token}"
|
|
101
|
-
}
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
def write_codeclimate_yaml
|
|
105
|
-
write_generator_file(".codeclimate.yml")
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
def write_rubocop_yamls
|
|
109
|
-
%w[.rubocop.yml .rubocop_cc.yml .rubocop_local.yml].each do |file|
|
|
110
|
-
write_generator_file(file)
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
def write_generator_file(file)
|
|
115
|
-
content = RestClient.get("https://raw.githubusercontent.com/ManageIQ/manageiq/master/lib/generators/manageiq/plugin/templates/#{file}").body
|
|
116
|
-
repo.write_file(file, content, dry_run: dry_run)
|
|
117
|
-
end
|
|
118
|
-
end
|
|
119
|
-
end
|