manageiq-cross_repo 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -0
- data/exe/manageiq-cross_repo +8 -0
- data/lib/manageiq/cross_repo/repository.rb +86 -27
- data/lib/manageiq/cross_repo/runner.rb +2 -2
- data/lib/manageiq/cross_repo/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 239fd403cb0702b0dc46c14a2091f60f6c3026eb9e2a4ba8177e2673111db23f
|
4
|
+
data.tar.gz: 65e594c923e080920fba7a24aa0ce75e31affa600e2f95238ff896c817dd597a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a19241876f9e0d0911dd4ee6b5912ead8349b0c4acd648db93dca59d8f992f89130eb08e54efefb1472269c8f240ccefc29b94d2c469b5c85c6aaa1f37330cb
|
7
|
+
data.tar.gz: 120fbc5e638502dd731e3b37571595ff68f6125f54e37fed218a563d03c8e6e53a4e5291b33d1d8f2b40772a8221b43837cacdc0a47abc46855c637fd58224cf
|
data/README.md
CHANGED
@@ -29,6 +29,9 @@ Repo Formats:
|
|
29
29
|
@ref: Optional, defaults to master if #pr not set. Can be a branch, tag, or SHA. Mutually exclusive with #pr.
|
30
30
|
#pr: Optional, references a pull-request number. Mutually exclusive with @ref.
|
31
31
|
|
32
|
+
URL: https://github.com/org/repository, https://github.com/org/repository/tree/branch,
|
33
|
+
https://github.com/org/repository/commit/sha, https://github.com/org/repository/pull/pr
|
34
|
+
|
32
35
|
Local: Either a fully qualified path or a relative path (e.g. /path/to/repo, ~/relative/to/home, ../relative/to/current/dir)
|
33
36
|
|
34
37
|
Examples:
|
data/exe/manageiq-cross_repo
CHANGED
@@ -49,6 +49,9 @@ opts = Optimist.options do
|
|
49
49
|
@ref: Optional, defaults to master if #pr not set. Can be a branch, tag, or SHA. Mutually exclusive with #pr.
|
50
50
|
#pr: Optional, references a pull-request number. Mutually exclusive with @ref.
|
51
51
|
|
52
|
+
URL: https://github.com/org/repository, https://github.com/org/repository/tree/branch,
|
53
|
+
https://github.com/org/repository/commit/sha, https://github.com/org/repository/pull/pr
|
54
|
+
|
52
55
|
Local: Either a fully qualified path or a relative path (e.g. /path/to/repo, ~/relative/to/home, ../relative/to/current/dir)
|
53
56
|
EOS
|
54
57
|
|
@@ -86,6 +89,11 @@ end
|
|
86
89
|
|
87
90
|
opts[:gem_repos] = opts[:gem_repos].flatten.flat_map { |repo| repo.split(",").map(&:strip) }
|
88
91
|
|
92
|
+
if ENV["CI"] && opts[:test_repo] == "ManageIQ/manageiq@master" && opts[:core_repo].blank? && opts[:gem_repos].blank?
|
93
|
+
puts "Nothing to do!"
|
94
|
+
exit
|
95
|
+
end
|
96
|
+
|
89
97
|
begin
|
90
98
|
ManageIQ::CrossRepo.run(opts[:test_repo], opts[:core_repo], opts[:gem_repos])
|
91
99
|
rescue ArgumentError => e
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module ManageIQ::CrossRepo
|
2
2
|
class Repository
|
3
|
-
|
3
|
+
attr_reader :identifier, :server
|
4
|
+
attr_reader :org, :repo, :ref, :sha, :url, :path
|
4
5
|
|
5
6
|
# ManageIQ::CrossRepo::Repository
|
6
7
|
#
|
@@ -9,7 +10,9 @@ module ManageIQ::CrossRepo
|
|
9
10
|
# @example
|
10
11
|
# Repostory.new("ManageIQ/manageiq@master", server: "https://github.com")
|
11
12
|
def initialize(identifier, server: "https://github.com")
|
12
|
-
@
|
13
|
+
@identifier = identifier
|
14
|
+
@server = server
|
15
|
+
@org, @repo, @ref, @sha, @url, @path = parse_identifier
|
13
16
|
end
|
14
17
|
|
15
18
|
def core?
|
@@ -37,34 +40,91 @@ module ManageIQ::CrossRepo
|
|
37
40
|
|
38
41
|
private
|
39
42
|
|
40
|
-
def parse_identifier
|
41
|
-
if
|
42
|
-
|
43
|
-
|
43
|
+
def parse_identifier
|
44
|
+
if local_identifier?
|
45
|
+
parse_local_identifier
|
46
|
+
elsif url_identifier?
|
47
|
+
parse_url_identifier
|
48
|
+
else
|
49
|
+
parse_repo_identifier
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def local_identifier?
|
54
|
+
["/", "~", "."].include?(identifier[0])
|
55
|
+
end
|
56
|
+
|
57
|
+
def parse_local_identifier
|
58
|
+
path = Pathname.new(identifier).expand_path
|
59
|
+
raise ArgumentError, "Path #{path} does not exist" unless path.exist?
|
60
|
+
|
61
|
+
org = nil
|
62
|
+
repo = path.basename.to_s
|
63
|
+
ref = Dir.chdir(path) { `git rev-parse HEAD`.chomp }
|
64
|
+
sha = ref
|
65
|
+
url = nil
|
66
|
+
|
67
|
+
return org, repo, ref, sha, url, path
|
68
|
+
end
|
69
|
+
|
70
|
+
def url_identifier?
|
71
|
+
identifier.start_with?(server)
|
72
|
+
end
|
73
|
+
|
74
|
+
def parse_url_identifier
|
75
|
+
url_path = URI.parse(identifier).path
|
76
|
+
_, org, repo, type, commit_branch_or_pr = url_path.split("/")
|
77
|
+
|
78
|
+
case type
|
79
|
+
when "tree"
|
80
|
+
branch = commit_branch_or_pr
|
81
|
+
when "commit"
|
82
|
+
commit = commit_branch_or_pr
|
83
|
+
when "pull"
|
84
|
+
pr = commit_branch_or_pr
|
85
|
+
else
|
86
|
+
branch = "master"
|
87
|
+
end
|
88
|
+
|
89
|
+
url = File.join(server, org, repo)
|
90
|
+
sha =
|
91
|
+
if pr
|
92
|
+
git_pr_to_sha(url, pr)
|
93
|
+
elsif branch
|
94
|
+
git_branch_to_sha(url, branch)
|
95
|
+
else
|
96
|
+
commit
|
97
|
+
end
|
44
98
|
|
45
|
-
|
46
|
-
|
47
|
-
|
99
|
+
raise ArgumentError, "#{identifier} does not exist" if sha.nil?
|
100
|
+
|
101
|
+
ref = nil
|
102
|
+
path = REPOS_DIR.join("#{org}/#{repo}@#{sha}")
|
103
|
+
|
104
|
+
return org, repo, ref, sha, url, path
|
105
|
+
end
|
106
|
+
|
107
|
+
def parse_repo_identifier
|
108
|
+
if identifier.include?("#")
|
109
|
+
name, pr = identifier.split("#")
|
48
110
|
else
|
49
|
-
|
50
|
-
|
111
|
+
name, ref_or_branch = identifier.split("@")
|
112
|
+
if ref_or_branch.nil?
|
113
|
+
branch = "master"
|
114
|
+
elsif ref_or_branch.match?(/^\h+$/)
|
115
|
+
ref = ref_or_branch
|
51
116
|
else
|
52
|
-
|
53
|
-
if ref_or_branch.nil?
|
54
|
-
branch = "master"
|
55
|
-
elsif ref_or_branch.match?(/^\h+$/)
|
56
|
-
ref = ref_or_branch
|
57
|
-
else
|
58
|
-
branch = ref_or_branch
|
59
|
-
end
|
117
|
+
branch = ref_or_branch
|
60
118
|
end
|
119
|
+
end
|
61
120
|
|
62
|
-
|
63
|
-
|
121
|
+
org, repo = name.split("/")
|
122
|
+
repo, org = org, "ManageIQ" if repo.nil?
|
64
123
|
|
65
|
-
|
124
|
+
url = File.join(server, org, repo)
|
66
125
|
|
67
|
-
|
126
|
+
sha =
|
127
|
+
if pr
|
68
128
|
git_pr_to_sha(url, pr)
|
69
129
|
elsif branch
|
70
130
|
git_branch_to_sha(url, branch)
|
@@ -72,10 +132,9 @@ module ManageIQ::CrossRepo
|
|
72
132
|
ref
|
73
133
|
end
|
74
134
|
|
75
|
-
|
135
|
+
raise ArgumentError, "#{identifier} does not exist" if sha.nil?
|
76
136
|
|
77
|
-
|
78
|
-
end
|
137
|
+
path = REPOS_DIR.join("#{org}/#{repo}@#{sha}")
|
79
138
|
|
80
139
|
return org, repo, ref, sha, url, path
|
81
140
|
end
|
@@ -89,7 +148,7 @@ module ManageIQ::CrossRepo
|
|
89
148
|
end
|
90
149
|
|
91
150
|
def git_pr_to_sha(url, pr)
|
92
|
-
|
151
|
+
git_branch_to_sha(url, "refs/pull/#{pr}/head")
|
93
152
|
end
|
94
153
|
end
|
95
154
|
end
|
@@ -58,7 +58,7 @@ module ManageIQ::CrossRepo
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def system!(*args)
|
61
|
-
exit(
|
61
|
+
exit($?.exitstatus) unless system(*args)
|
62
62
|
end
|
63
63
|
|
64
64
|
def generate_bundler_d
|
@@ -68,7 +68,7 @@ module ManageIQ::CrossRepo
|
|
68
68
|
if gem_repos.empty?
|
69
69
|
FileUtils.rm_f override_path
|
70
70
|
else
|
71
|
-
content = gem_repos.map { |gem| "
|
71
|
+
content = gem_repos.map { |gem| "ensure_gem \"#{gem.repo}\", :path => \"#{gem.path}\"" }.join("\n")
|
72
72
|
FileUtils.mkdir_p(bundler_d_path)
|
73
73
|
|
74
74
|
File.write(override_path, content)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: manageiq-cross_repo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.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: 2019-10-
|
11
|
+
date: 2019-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|