esr-rim 1.4.0 → 1.4.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/CHANGELOG +33 -0
- data/Rakefile +56 -56
- data/lib/rim/command/sync.rb +89 -89
- data/lib/rim/command_helper.rb +144 -143
- data/lib/rim/dirty_check.rb +9 -2
- data/lib/rim/file_helper.rb +0 -2
- data/lib/rim/git.rb +9 -1
- data/lib/rim/info_helper.rb +5 -1
- data/lib/rim/info_module_helper.rb +5 -0
- data/lib/rim/manifest/helper.rb +82 -82
- data/lib/rim/manifest/json_reader.rb +41 -41
- data/lib/rim/manifest/manifest.json +7 -7
- data/lib/rim/module_helper.rb +57 -57
- data/lib/rim/module_info.rb +43 -43
- data/lib/rim/processor.rb +152 -152
- data/lib/rim/rim.rb +94 -94
- data/lib/rim/rim_info.rb +2 -0
- data/lib/rim/sync_helper.rb +150 -150
- data/lib/rim/sync_module_helper.rb +107 -107
- data/lib/rim/upload_helper.rb +69 -69
- data/lib/rim/upload_module_helper.rb +163 -162
- data/lib/rim/version.rb +1 -2
- data/test/command_helper_test.rb +83 -83
- data/test/file_helper_test.rb +132 -132
- data/test/manifest_helper_test.rb +29 -29
- data/test/manifest_test_dir/manifest.rim +9 -9
- data/test/processor_test.rb +32 -32
- data/test/sync_helper_test.rb +296 -296
- data/test/sync_module_helper_test.rb +126 -126
- data/test/upload_helper_test.rb +403 -403
- data/test/upload_module_helper_test.rb +92 -92
- metadata +10 -17
- data/test/dirty_check/dir1/file2 +0 -1
- data/test/dirty_check/file1 +0 -1
- data/test/dirty_check/ign_file1 +0 -1
- data/test/rim_info/mod1/dir1/file2 +0 -1
- data/test/rim_info/mod1/file1 +0 -1
- data/test/rim_info/unrelated_file +0 -1
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
MWFjMjVhMTY4YzYyNGQxMTRmNDVlNzU1ZjNiOTdiZmMyOGYzODZmNQ==
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: fcc043a75a2e7ae9e71845c67334e79ee0ba6aaf085448b43b198e5139ed944e
|
4
|
+
data.tar.gz: 57902a94583ad811f020ab215e0b3466ea3e19a10bba8803248d50ffa0eaa509
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
Y2VmNDNkMGJjODNmYzU1M2E0ZmMxMWM3ODgxOTAxNWI2M2VjZDRlNmJkMGFk
|
11
|
-
MGQ1NTE3YTI4MmFhYjk4NDBmNzYzODk3NmE3ZTkzYTJiZjU3N2Y=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
NTg0MzcxODM3YjQyYjVjM2JjY2I1N2ZiMDZmNDZlZTI0YjM3NWM2YjA1NmY2
|
14
|
-
YmQzYjdhNzE1MWFjNTI4NmI3ZjIyYzc1ZTRlZGM0YjYyYzgxMWYzY2FkZDc3
|
15
|
-
YmExNjgxZDI0ZjEyOTE0MjkyMDY1YzFmNjJlODczNGY3NTkxMmE=
|
6
|
+
metadata.gz: 23426845fa800c04800a41ea845f73db9ac1be42d207923b32d3c9f10bb10a7da03772b5737de3d6dee495ec322ffd13d998c7d8e478fb3919e8d386b5b3cb14
|
7
|
+
data.tar.gz: f090d3ffd8bfeb1603a6e168709cb047a41894a64ef1c215a344f3452d659a17d2b68cb189135d91a31c41cdd46d730d73bc655399c7affbd6ed67ea40dcc989
|
data/CHANGELOG
CHANGED
@@ -126,3 +126,36 @@
|
|
126
126
|
# 1.4.0
|
127
127
|
|
128
128
|
* fixed Issue #20: Add revision timestamp to .riminfo
|
129
|
+
|
130
|
+
# 1.4.1
|
131
|
+
|
132
|
+
* Allow changing sub directory path to empty string
|
133
|
+
* Fix tar usage for Windows
|
134
|
+
|
135
|
+
# 1.4.2
|
136
|
+
|
137
|
+
* Fixed temporary-folder-generation on Windows, which could e.g. break the dirty check
|
138
|
+
|
139
|
+
# 1.4.3
|
140
|
+
|
141
|
+
* Fixed ignore-filter which could break if temporary files are created and deleted in parallel processes
|
142
|
+
|
143
|
+
# 1.4.4
|
144
|
+
|
145
|
+
* Fixed exception which results in ugly log output for Ruby >= 2.5
|
146
|
+
|
147
|
+
# 1.4.5
|
148
|
+
|
149
|
+
* Wrong build: deprecated
|
150
|
+
|
151
|
+
# 1.4.6
|
152
|
+
|
153
|
+
* Fixed issue #28: rim sync is not working in root of destination repository
|
154
|
+
|
155
|
+
# 1.4.7
|
156
|
+
|
157
|
+
* Added a notification in `rim info` in case the current SHA1 is not an existing commit
|
158
|
+
|
159
|
+
# 1.4.8
|
160
|
+
|
161
|
+
* Fixed exception while reading empty .riminfo files
|
data/Rakefile
CHANGED
@@ -1,56 +1,56 @@
|
|
1
|
-
$:.unshift(File.dirname(__FILE__)+"/lib")
|
2
|
-
|
3
|
-
require 'rubygems/package_task'
|
4
|
-
require 'rdoc/task'
|
5
|
-
require 'rim/version'
|
6
|
-
|
7
|
-
DocFiles = [
|
8
|
-
"README.md", "CHANGELOG"
|
9
|
-
]
|
10
|
-
|
11
|
-
RTextGemSpec = Gem::Specification.new do |s|
|
12
|
-
s.name = "esr-rim"
|
13
|
-
s.version = RIM::Version::Version
|
14
|
-
s.date = Time.now.strftime("%Y-%m-%d")
|
15
|
-
s.summary = "RIM - multi git tool"
|
16
|
-
s.description = "RIM lets you work with multiple git repositories from within one single git repository."
|
17
|
-
s.authors = "ESR Labs
|
18
|
-
s.homepage = "http://github.com/esrlabs/esr-rim"
|
19
|
-
s.add_dependency('subcommand', '>= 1.0.6')
|
20
|
-
gemfiles = Rake::FileList.new
|
21
|
-
gemfiles.include("{lib,test}/**/*")
|
22
|
-
gemfiles.include(DocFiles)
|
23
|
-
gemfiles.include("Rakefile")
|
24
|
-
s.files = gemfiles
|
25
|
-
s.rdoc_options = ["--main", "README.md", "-x", "test"]
|
26
|
-
s.extra_rdoc_files = DocFiles
|
27
|
-
s.bindir = "bin"
|
28
|
-
s.executables = ["rim"]
|
29
|
-
end
|
30
|
-
|
31
|
-
RDoc::Task.new do |rd|
|
32
|
-
rd.main = "README.md"
|
33
|
-
rd.rdoc_files.include(DocFiles)
|
34
|
-
rd.rdoc_files.include("lib/**/*.rb")
|
35
|
-
rd.rdoc_dir = "doc"
|
36
|
-
end
|
37
|
-
|
38
|
-
RTextPackageTask = Gem::PackageTask.new(RTextGemSpec) do |p|
|
39
|
-
p.need_zip = false
|
40
|
-
end
|
41
|
-
|
42
|
-
task :prepare_package_rdoc => :rdoc do
|
43
|
-
RTextPackageTask.package_files.include("doc/**/*")
|
44
|
-
end
|
45
|
-
|
46
|
-
desc 'run unit tests'
|
47
|
-
task :
|
48
|
-
sh "ruby test/unit_tests.rb"
|
49
|
-
end
|
50
|
-
|
51
|
-
task :release => [:prepare_package_rdoc, :package]
|
52
|
-
|
53
|
-
task :clobber => [:clobber_rdoc, :clobber_package]
|
54
|
-
|
55
|
-
task :default => :run_tests
|
56
|
-
|
1
|
+
$:.unshift(File.dirname(__FILE__)+"/lib")
|
2
|
+
|
3
|
+
require 'rubygems/package_task'
|
4
|
+
require 'rdoc/task'
|
5
|
+
require 'rim/version'
|
6
|
+
|
7
|
+
DocFiles = [
|
8
|
+
"README.md", "CHANGELOG"
|
9
|
+
]
|
10
|
+
|
11
|
+
RTextGemSpec = Gem::Specification.new do |s|
|
12
|
+
s.name = "esr-rim"
|
13
|
+
s.version = RIM::Version::Version
|
14
|
+
s.date = Time.now.strftime("%Y-%m-%d")
|
15
|
+
s.summary = "RIM - multi git tool"
|
16
|
+
s.description = "RIM lets you work with multiple git repositories from within one single git repository."
|
17
|
+
s.authors = "ESR Labs GmbH"
|
18
|
+
s.homepage = "http://github.com/esrlabs/esr-rim"
|
19
|
+
s.add_dependency('subcommand', '>= 1.0.6')
|
20
|
+
gemfiles = Rake::FileList.new
|
21
|
+
gemfiles.include("{lib,test}/**/*")
|
22
|
+
gemfiles.include(DocFiles)
|
23
|
+
gemfiles.include("Rakefile")
|
24
|
+
s.files = gemfiles
|
25
|
+
s.rdoc_options = ["--main", "README.md", "-x", "test"]
|
26
|
+
s.extra_rdoc_files = DocFiles
|
27
|
+
s.bindir = "bin"
|
28
|
+
s.executables = ["rim"]
|
29
|
+
end
|
30
|
+
|
31
|
+
RDoc::Task.new do |rd|
|
32
|
+
rd.main = "README.md"
|
33
|
+
rd.rdoc_files.include(DocFiles)
|
34
|
+
rd.rdoc_files.include("lib/**/*.rb")
|
35
|
+
rd.rdoc_dir = "doc"
|
36
|
+
end
|
37
|
+
|
38
|
+
RTextPackageTask = Gem::PackageTask.new(RTextGemSpec) do |p|
|
39
|
+
p.need_zip = false
|
40
|
+
end
|
41
|
+
|
42
|
+
task :prepare_package_rdoc => :rdoc do
|
43
|
+
RTextPackageTask.package_files.include("doc/**/*")
|
44
|
+
end
|
45
|
+
|
46
|
+
desc 'run unit tests'
|
47
|
+
task :unit_tests do
|
48
|
+
sh "ruby test/unit_tests.rb"
|
49
|
+
end
|
50
|
+
|
51
|
+
task :release => [:prepare_package_rdoc, :package]
|
52
|
+
|
53
|
+
task :clobber => [:clobber_rdoc, :clobber_package]
|
54
|
+
|
55
|
+
task :default => :run_tests
|
56
|
+
|
data/lib/rim/command/sync.rb
CHANGED
@@ -1,89 +1,89 @@
|
|
1
|
-
require 'rim/command/command'
|
2
|
-
require 'rim/manifest/helper'
|
3
|
-
require 'rim/rim_exception'
|
4
|
-
require 'rim/rim_info'
|
5
|
-
require 'rim/sync_helper'
|
6
|
-
require 'uri'
|
7
|
-
|
8
|
-
module RIM
|
9
|
-
module Command
|
10
|
-
|
11
|
-
class Sync < Command
|
12
|
-
|
13
|
-
include RIM::Manifest
|
14
|
-
|
15
|
-
def initialize(opts)
|
16
|
-
opts.banner = "Usage: rim sync [<options>] [<local_module_path>]"
|
17
|
-
opts.description = "Synchronize specified rim modules with remote repository revisions."
|
18
|
-
opts.separator ""
|
19
|
-
opts.on("-m", "--manifest [MANIFEST]", String, "Read information from manifest.", \
|
20
|
-
"If no manifest file is specified a 'manifest.rim' file will be used.") do |manifest|
|
21
|
-
@manifest = manifest ? manifest : Helpers::default_manifest
|
22
|
-
end
|
23
|
-
opts.on("-c", "--create", "Synchronize module initially to <local_module_path>.", \
|
24
|
-
"Specify the remote URL and the target revision with the options.") do
|
25
|
-
@create = true
|
26
|
-
end
|
27
|
-
opts.on("-a", "--all", "Collects all modules from the specified paths.") do
|
28
|
-
@all = true
|
29
|
-
end
|
30
|
-
opts.on("-e", "--exclude PATTERN_LIST", String, "Exclude all modules of a comma separated list of directories when using sync with -a option.") do |dirlist|
|
31
|
-
@excludedirs = dirlist.split(",")
|
32
|
-
end
|
33
|
-
@module_options = {}
|
34
|
-
opts.on("-u", "--remote-url URL", String, "Set the remote URL of the module.", \
|
35
|
-
"A relative path will be applied to ssh://gerrit/") do |url|
|
36
|
-
@module_options[:remote_url] = url
|
37
|
-
end
|
38
|
-
opts.on("-r", "--target-revision REVISION", String, "Set the target revision of the module.") do |target_revision|
|
39
|
-
@module_options[:target_revision] = target_revision
|
40
|
-
end
|
41
|
-
opts.on("-i", "--ignore PATTERN_LIST", String, "Set the ignore patterns by specifying a comma separated list.") do |ignores|
|
42
|
-
@module_options[:ignores] = ignores || ""
|
43
|
-
end
|
44
|
-
opts.on("-m", "--message MESSAGE", String, "Message header to provide to each commit.") do |message|
|
45
|
-
@message = message
|
46
|
-
end
|
47
|
-
opts.on("-d", "--subdir SUBDIR", String, "Sync just a subdir from the remote module.") do |subdir|
|
48
|
-
@module_options[:subdir] = subdir
|
49
|
-
end
|
50
|
-
opts.on("-s", "--split", "Create a separate commit for each module.") do
|
51
|
-
@split = true
|
52
|
-
end
|
53
|
-
opts.on("-b", "--rebase", "Rebase after successful sync.") do
|
54
|
-
@rebase = true
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def invoke()
|
59
|
-
helper = SyncHelper.new(project_git_dir, @logger)
|
60
|
-
if @manifest
|
61
|
-
helper.modules_from_manifest(@manifest)
|
62
|
-
elsif @create
|
63
|
-
local_path = ARGV.shift || "."
|
64
|
-
if helper.find_file_dir_in_workspace(local_path, RimInfo::InfoFileName)
|
65
|
-
raise RimException.new("There's already a module file. Don't use the create option to sync the module.")
|
66
|
-
elsif !@module_options[:remote_url] || !@module_options[:target_revision]
|
67
|
-
raise RimException.new("Please specify remote URL and target revision for the new module.")
|
68
|
-
else
|
69
|
-
helper.add_module_info(helper.create_module_info(
|
70
|
-
@module_options[:remote_url],
|
71
|
-
local_path,
|
72
|
-
@module_options[:target_revision],
|
73
|
-
@module_options[:ignores],
|
74
|
-
@module_options[:subdir],
|
75
|
-
))
|
76
|
-
end
|
77
|
-
else
|
78
|
-
helper.modules_from_paths(@all ? helper.module_paths(ARGV, @excludedirs) : ARGV, @module_options)
|
79
|
-
end
|
80
|
-
helper.check_arguments
|
81
|
-
helper.sync(@message, @rebase, @split)
|
82
|
-
end
|
83
|
-
|
84
|
-
end
|
85
|
-
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
|
1
|
+
require 'rim/command/command'
|
2
|
+
require 'rim/manifest/helper'
|
3
|
+
require 'rim/rim_exception'
|
4
|
+
require 'rim/rim_info'
|
5
|
+
require 'rim/sync_helper'
|
6
|
+
require 'uri'
|
7
|
+
|
8
|
+
module RIM
|
9
|
+
module Command
|
10
|
+
|
11
|
+
class Sync < Command
|
12
|
+
|
13
|
+
include RIM::Manifest
|
14
|
+
|
15
|
+
def initialize(opts)
|
16
|
+
opts.banner = "Usage: rim sync [<options>] [<local_module_path>]"
|
17
|
+
opts.description = "Synchronize specified rim modules with remote repository revisions."
|
18
|
+
opts.separator ""
|
19
|
+
opts.on("-m", "--manifest [MANIFEST]", String, "Read information from manifest.", \
|
20
|
+
"If no manifest file is specified a 'manifest.rim' file will be used.") do |manifest|
|
21
|
+
@manifest = manifest ? manifest : Helpers::default_manifest
|
22
|
+
end
|
23
|
+
opts.on("-c", "--create", "Synchronize module initially to <local_module_path>.", \
|
24
|
+
"Specify the remote URL and the target revision with the options.") do
|
25
|
+
@create = true
|
26
|
+
end
|
27
|
+
opts.on("-a", "--all", "Collects all modules from the specified paths.") do
|
28
|
+
@all = true
|
29
|
+
end
|
30
|
+
opts.on("-e", "--exclude PATTERN_LIST", String, "Exclude all modules of a comma separated list of directories when using sync with -a option.") do |dirlist|
|
31
|
+
@excludedirs = dirlist.split(",")
|
32
|
+
end
|
33
|
+
@module_options = {}
|
34
|
+
opts.on("-u", "--remote-url URL", String, "Set the remote URL of the module.", \
|
35
|
+
"A relative path will be applied to ssh://gerrit/") do |url|
|
36
|
+
@module_options[:remote_url] = url
|
37
|
+
end
|
38
|
+
opts.on("-r", "--target-revision REVISION", String, "Set the target revision of the module.") do |target_revision|
|
39
|
+
@module_options[:target_revision] = target_revision
|
40
|
+
end
|
41
|
+
opts.on("-i", "--ignore PATTERN_LIST", String, "Set the ignore patterns by specifying a comma separated list.") do |ignores|
|
42
|
+
@module_options[:ignores] = ignores || ""
|
43
|
+
end
|
44
|
+
opts.on("-m", "--message MESSAGE", String, "Message header to provide to each commit.") do |message|
|
45
|
+
@message = message
|
46
|
+
end
|
47
|
+
opts.on("-d", "--subdir [SUBDIR]", String, "Sync just a subdir from the remote module.") do |subdir|
|
48
|
+
@module_options[:subdir] = subdir || ''
|
49
|
+
end
|
50
|
+
opts.on("-s", "--split", "Create a separate commit for each module.") do
|
51
|
+
@split = true
|
52
|
+
end
|
53
|
+
opts.on("-b", "--rebase", "Rebase after successful sync.") do
|
54
|
+
@rebase = true
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def invoke()
|
59
|
+
helper = SyncHelper.new(project_git_dir, @logger)
|
60
|
+
if @manifest
|
61
|
+
helper.modules_from_manifest(@manifest)
|
62
|
+
elsif @create
|
63
|
+
local_path = ARGV.shift || "."
|
64
|
+
if helper.find_file_dir_in_workspace(local_path, RimInfo::InfoFileName)
|
65
|
+
raise RimException.new("There's already a module file. Don't use the create option to sync the module.")
|
66
|
+
elsif !@module_options[:remote_url] || !@module_options[:target_revision]
|
67
|
+
raise RimException.new("Please specify remote URL and target revision for the new module.")
|
68
|
+
else
|
69
|
+
helper.add_module_info(helper.create_module_info(
|
70
|
+
@module_options[:remote_url],
|
71
|
+
local_path,
|
72
|
+
@module_options[:target_revision],
|
73
|
+
@module_options[:ignores],
|
74
|
+
@module_options[:subdir],
|
75
|
+
))
|
76
|
+
end
|
77
|
+
else
|
78
|
+
helper.modules_from_paths(@all ? helper.module_paths(ARGV, @excludedirs) : ARGV, @module_options)
|
79
|
+
end
|
80
|
+
helper.check_arguments
|
81
|
+
helper.sync(@message, @rebase, @split)
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
|
data/lib/rim/command_helper.rb
CHANGED
@@ -1,143 +1,144 @@
|
|
1
|
-
require 'rim/file_helper'
|
2
|
-
require 'rim/processor'
|
3
|
-
require 'rim/module_info'
|
4
|
-
require 'rim/rim_info'
|
5
|
-
require 'rim/manifest/json_reader'
|
6
|
-
require 'rim/status_builder'
|
7
|
-
require 'pathname'
|
8
|
-
|
9
|
-
module RIM
|
10
|
-
|
11
|
-
class CommandHelper < Processor
|
12
|
-
|
13
|
-
include Manifest
|
14
|
-
|
15
|
-
def initialize(workspace_root, logger, module_infos = nil)
|
16
|
-
super(workspace_root, logger)
|
17
|
-
@paths = []
|
18
|
-
@logger = logger
|
19
|
-
if module_infos
|
20
|
-
module_infos.each do |m|
|
21
|
-
add_module_info(m)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
# check whether workspace is not touched
|
27
|
-
def check_ready
|
28
|
-
raise RimException.new("The workspace git contains uncommitted changes.") if !local_changes?(@ws_root)
|
29
|
-
end
|
30
|
-
|
31
|
-
def check_arguments
|
32
|
-
raise RimException.new("Unexpected command line arguments.") if !ARGV.empty?
|
33
|
-
end
|
34
|
-
|
35
|
-
def create_module_info(remote_url, local_path, target_revision, ignores, subdir)
|
36
|
-
ModuleInfo.new(
|
37
|
-
remote_url,
|
38
|
-
get_relative_path(local_path),
|
39
|
-
target_revision,
|
40
|
-
ignores,
|
41
|
-
remote_url ? get_remote_branch_format(remote_url) : nil,
|
42
|
-
subdir)
|
43
|
-
end
|
44
|
-
|
45
|
-
def modules_from_manifest(path)
|
46
|
-
manifest = read_manifest(path)
|
47
|
-
manifest.modules.each do |mod|
|
48
|
-
add_unique_module_info(create_module_info(mod.remote_path, mod.local_path, mod.target_revision, mod.ignores, mod.subdir))
|
49
|
-
end
|
50
|
-
true
|
51
|
-
end
|
52
|
-
|
53
|
-
def modules_from_paths(paths, opts = {})
|
54
|
-
if paths.empty?
|
55
|
-
module_from_path(nil, opts)
|
56
|
-
elsif paths.length == 1 || !opts.has_key?(:remote_url)
|
57
|
-
while !paths.empty?
|
58
|
-
module_from_path(paths.shift, opts)
|
59
|
-
end
|
60
|
-
else
|
61
|
-
raise RimException.new("Multiple modules cannot be used with URL option.")
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def module_from_path(path, opts = {})
|
66
|
-
module_path = find_file_dir_in_workspace(path || ".", RimInfo::InfoFileName)
|
67
|
-
if module_path
|
68
|
-
rim_info = RimInfo.from_dir(module_path)
|
69
|
-
module_info = create_module_info(
|
70
|
-
opts.has_key?(:remote_url) ? opts[:remote_url] : rim_info.remote_url,
|
71
|
-
module_path,
|
72
|
-
opts.has_key?(:target_revision) ? opts[:target_revision] : rim_info.target_revision,
|
73
|
-
opts.has_key?(:ignores) ? opts[:ignores] : rim_info.ignores,
|
74
|
-
opts.has_key?(:subdir) ? opts[:subdir] : rim_info.subdir)
|
75
|
-
if module_info.valid?
|
76
|
-
add_unique_module_info(module_info)
|
77
|
-
module_path
|
78
|
-
else
|
79
|
-
raise RimException.new("Invalid .riminfo file found in directory '#{module_path}'.")
|
80
|
-
end
|
81
|
-
else
|
82
|
-
raise RimException.new(path ? "No module info found in '#{path}'." : "No module info found.")
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
def module_paths(paths, exclude_paths = nil)
|
87
|
-
module_paths = []
|
88
|
-
(paths.empty? ? ['.'] : paths).each do |p|
|
89
|
-
module_paths.concat(all_module_paths_from_path(p))
|
90
|
-
end
|
91
|
-
paths.clear
|
92
|
-
if exclude_paths
|
93
|
-
exclude_paths.each do |e|
|
94
|
-
all_module_paths_from_path(e).each do |p|
|
95
|
-
module_paths.delete(p)
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
module_paths.sort
|
100
|
-
end
|
101
|
-
|
102
|
-
def all_module_paths_from_path(path)
|
103
|
-
Dir.glob(File.join(path, "**/.riminfo")).map { |f| Pathname.new(File.expand_path(File.dirname(f))).relative_path_from(Pathname.pwd).to_s }
|
104
|
-
end
|
105
|
-
|
106
|
-
def add_unique_module_info(module_info)
|
107
|
-
if !@paths.include?(module_info.local_path)
|
108
|
-
@paths.push(module_info.local_path)
|
109
|
-
add_module_info(module_info)
|
110
|
-
else
|
111
|
-
raise RimException.new("Module '#{module_info.local_path}' specified more than once.")
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
def get_remote_branch_format(remote_url)
|
116
|
-
get_absolute_remote_url(remote_url).start_with?(GerritServer) ? "refs/for/%s" : nil
|
117
|
-
#"refs/for/%s"
|
118
|
-
end
|
119
|
-
|
120
|
-
def find_file_dir_in_workspace(start_dir, file)
|
121
|
-
path = File.expand_path(start_dir)
|
122
|
-
|
123
|
-
if File.exist?(File.join(path, file))
|
124
|
-
return path
|
125
|
-
|
126
|
-
parent = File.dirname(path)
|
127
|
-
if parent != path
|
128
|
-
path = parent
|
129
|
-
else
|
130
|
-
|
131
|
-
end
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
1
|
+
require 'rim/file_helper'
|
2
|
+
require 'rim/processor'
|
3
|
+
require 'rim/module_info'
|
4
|
+
require 'rim/rim_info'
|
5
|
+
require 'rim/manifest/json_reader'
|
6
|
+
require 'rim/status_builder'
|
7
|
+
require 'pathname'
|
8
|
+
|
9
|
+
module RIM
|
10
|
+
|
11
|
+
class CommandHelper < Processor
|
12
|
+
|
13
|
+
include Manifest
|
14
|
+
|
15
|
+
def initialize(workspace_root, logger, module_infos = nil)
|
16
|
+
super(workspace_root, logger)
|
17
|
+
@paths = []
|
18
|
+
@logger = logger
|
19
|
+
if module_infos
|
20
|
+
module_infos.each do |m|
|
21
|
+
add_module_info(m)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# check whether workspace is not touched
|
27
|
+
def check_ready
|
28
|
+
raise RimException.new("The workspace git contains uncommitted changes.") if !local_changes?(@ws_root)
|
29
|
+
end
|
30
|
+
|
31
|
+
def check_arguments
|
32
|
+
raise RimException.new("Unexpected command line arguments.") if !ARGV.empty?
|
33
|
+
end
|
34
|
+
|
35
|
+
def create_module_info(remote_url, local_path, target_revision, ignores, subdir)
|
36
|
+
ModuleInfo.new(
|
37
|
+
remote_url,
|
38
|
+
get_relative_path(local_path),
|
39
|
+
target_revision,
|
40
|
+
ignores,
|
41
|
+
remote_url ? get_remote_branch_format(remote_url) : nil,
|
42
|
+
subdir)
|
43
|
+
end
|
44
|
+
|
45
|
+
def modules_from_manifest(path)
|
46
|
+
manifest = read_manifest(path)
|
47
|
+
manifest.modules.each do |mod|
|
48
|
+
add_unique_module_info(create_module_info(mod.remote_path, mod.local_path, mod.target_revision, mod.ignores, mod.subdir))
|
49
|
+
end
|
50
|
+
true
|
51
|
+
end
|
52
|
+
|
53
|
+
def modules_from_paths(paths, opts = {})
|
54
|
+
if paths.empty?
|
55
|
+
module_from_path(nil, opts)
|
56
|
+
elsif paths.length == 1 || !opts.has_key?(:remote_url)
|
57
|
+
while !paths.empty?
|
58
|
+
module_from_path(paths.shift, opts)
|
59
|
+
end
|
60
|
+
else
|
61
|
+
raise RimException.new("Multiple modules cannot be used with URL option.")
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def module_from_path(path, opts = {})
|
66
|
+
module_path = find_file_dir_in_workspace(path || ".", RimInfo::InfoFileName)
|
67
|
+
if module_path
|
68
|
+
rim_info = RimInfo.from_dir(module_path)
|
69
|
+
module_info = create_module_info(
|
70
|
+
opts.has_key?(:remote_url) ? opts[:remote_url] : rim_info.remote_url,
|
71
|
+
module_path,
|
72
|
+
opts.has_key?(:target_revision) ? opts[:target_revision] : rim_info.target_revision,
|
73
|
+
opts.has_key?(:ignores) ? opts[:ignores] : rim_info.ignores,
|
74
|
+
opts.has_key?(:subdir) ? opts[:subdir] : rim_info.subdir)
|
75
|
+
if module_info.valid?
|
76
|
+
add_unique_module_info(module_info)
|
77
|
+
module_path
|
78
|
+
else
|
79
|
+
raise RimException.new("Invalid .riminfo file found in directory '#{module_path}'.")
|
80
|
+
end
|
81
|
+
else
|
82
|
+
raise RimException.new(path ? "No module info found in '#{path}'." : "No module info found.")
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def module_paths(paths, exclude_paths = nil)
|
87
|
+
module_paths = []
|
88
|
+
(paths.empty? ? ['.'] : paths).each do |p|
|
89
|
+
module_paths.concat(all_module_paths_from_path(p))
|
90
|
+
end
|
91
|
+
paths.clear
|
92
|
+
if exclude_paths
|
93
|
+
exclude_paths.each do |e|
|
94
|
+
all_module_paths_from_path(e).each do |p|
|
95
|
+
module_paths.delete(p)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
module_paths.sort
|
100
|
+
end
|
101
|
+
|
102
|
+
def all_module_paths_from_path(path)
|
103
|
+
Dir.glob(File.join(path, "**/.riminfo")).map { |f| Pathname.new(File.expand_path(File.dirname(f))).relative_path_from(Pathname.pwd).to_s }
|
104
|
+
end
|
105
|
+
|
106
|
+
def add_unique_module_info(module_info)
|
107
|
+
if !@paths.include?(module_info.local_path)
|
108
|
+
@paths.push(module_info.local_path)
|
109
|
+
add_module_info(module_info)
|
110
|
+
else
|
111
|
+
raise RimException.new("Module '#{module_info.local_path}' specified more than once.")
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def get_remote_branch_format(remote_url)
|
116
|
+
get_absolute_remote_url(remote_url).start_with?(GerritServer) ? "refs/for/%s" : nil
|
117
|
+
#"refs/for/%s"
|
118
|
+
end
|
119
|
+
|
120
|
+
def find_file_dir_in_workspace(start_dir, file)
|
121
|
+
path = File.expand_path(start_dir)
|
122
|
+
loop do
|
123
|
+
if File.exist?(File.join(path, file))
|
124
|
+
return path
|
125
|
+
elsif path != @ws_root
|
126
|
+
parent = File.dirname(path)
|
127
|
+
if parent != path
|
128
|
+
path = parent
|
129
|
+
else
|
130
|
+
return nil
|
131
|
+
end
|
132
|
+
else
|
133
|
+
return nil
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
protected
|
139
|
+
def add_module_info(module_info)
|
140
|
+
end
|
141
|
+
|
142
|
+
end
|
143
|
+
|
144
|
+
end
|