esr-rim 1.4.0 → 1.4.2
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 +5 -13
- data/CHANGELOG +9 -0
- data/Rakefile +56 -56
- data/lib/rim/command/sync.rb +89 -89
- data/lib/rim/command_helper.rb +143 -143
- data/lib/rim/git.rb +2 -1
- 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/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 -1
- 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 +9 -15
- 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
data/lib/rim/git.rb
CHANGED
@@ -190,7 +190,7 @@ class GitSession
|
|
190
190
|
path_args << " "
|
191
191
|
path_args << paths.shift
|
192
192
|
end
|
193
|
-
execute "git archive --format tar #{rev} #{path_args} | tar -
|
193
|
+
execute "git archive --format tar #{rev} #{path_args} | tar -C #{dir} -xf -"
|
194
194
|
break if paths.empty?
|
195
195
|
end
|
196
196
|
end
|
@@ -200,6 +200,7 @@ class GitSession
|
|
200
200
|
# returns the value returned by the block
|
201
201
|
def within_exported_rev(rev, paths=[])
|
202
202
|
Dir.mktmpdir("rim") do |d|
|
203
|
+
d = Dir.glob(d)[0]
|
203
204
|
c = File.join(d, "content")
|
204
205
|
FileUtils.mkdir(c)
|
205
206
|
export_rev(rev, c, paths)
|
data/lib/rim/manifest/helper.rb
CHANGED
@@ -1,82 +1,82 @@
|
|
1
|
-
require 'monitor'
|
2
|
-
require 'pathname'
|
3
|
-
|
4
|
-
module RIM
|
5
|
-
module Manifest
|
6
|
-
|
7
|
-
class RimError < StandardError
|
8
|
-
def self.status_code(code)
|
9
|
-
define_method(:status_code) { code }
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
class ManifestFileNotFound < RimError; status_code(10) ; end
|
14
|
-
|
15
|
-
module Helpers
|
16
|
-
CHDIR_MONITOR = Monitor.new
|
17
|
-
CONFIG_FILE_NAME = "manifest.rim"
|
18
|
-
|
19
|
-
def default_manifest
|
20
|
-
manifest = find_manifest
|
21
|
-
raise ManifestFileNotFound, "Could not locate #{CONFIG_FILE_NAME}" unless manifest
|
22
|
-
Pathname.new(manifest)
|
23
|
-
end
|
24
|
-
|
25
|
-
def default_lockfile
|
26
|
-
manifest = default_manifest
|
27
|
-
Pathname.new(manifest.sub(/.rim$/, '.locked'))
|
28
|
-
end
|
29
|
-
|
30
|
-
def in_rim_project?
|
31
|
-
find_manifest
|
32
|
-
end
|
33
|
-
|
34
|
-
def chdir_monitor
|
35
|
-
CHDIR_MONITOR
|
36
|
-
end
|
37
|
-
|
38
|
-
def chdir(dir, &blk)
|
39
|
-
chdir_monitor.synchronize do
|
40
|
-
Dir.chdir dir, &blk
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
private
|
45
|
-
|
46
|
-
def find_manifest
|
47
|
-
given = ENV['RIM_MANIFEST']
|
48
|
-
return given if given && !given.empty?
|
49
|
-
|
50
|
-
find_file(CONFIG_FILE_NAME)
|
51
|
-
end
|
52
|
-
|
53
|
-
def find_file(*names)
|
54
|
-
search_up(*names) {|filename|
|
55
|
-
return filename if File.file?(filename)
|
56
|
-
}
|
57
|
-
end
|
58
|
-
|
59
|
-
def find_directory(*names)
|
60
|
-
search_up(*names) do |dirname|
|
61
|
-
return dirname if File.directory?(dirname)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def search_up(*names)
|
66
|
-
previous = nil
|
67
|
-
current = File.expand_path(Dir.pwd)
|
68
|
-
|
69
|
-
until !File.directory?(current) || current == previous
|
70
|
-
names.each do |name|
|
71
|
-
filename = File.join(current, name)
|
72
|
-
yield filename
|
73
|
-
end
|
74
|
-
current, previous = File.expand_path("..", current), current
|
75
|
-
end
|
76
|
-
end
|
77
|
-
extend self
|
78
|
-
end
|
79
|
-
|
80
|
-
end # Manifest
|
81
|
-
end # RIM
|
82
|
-
|
1
|
+
require 'monitor'
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
module RIM
|
5
|
+
module Manifest
|
6
|
+
|
7
|
+
class RimError < StandardError
|
8
|
+
def self.status_code(code)
|
9
|
+
define_method(:status_code) { code }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class ManifestFileNotFound < RimError; status_code(10) ; end
|
14
|
+
|
15
|
+
module Helpers
|
16
|
+
CHDIR_MONITOR = Monitor.new
|
17
|
+
CONFIG_FILE_NAME = "manifest.rim"
|
18
|
+
|
19
|
+
def default_manifest
|
20
|
+
manifest = find_manifest
|
21
|
+
raise ManifestFileNotFound, "Could not locate #{CONFIG_FILE_NAME}" unless manifest
|
22
|
+
Pathname.new(manifest)
|
23
|
+
end
|
24
|
+
|
25
|
+
def default_lockfile
|
26
|
+
manifest = default_manifest
|
27
|
+
Pathname.new(manifest.sub(/.rim$/, '.locked'))
|
28
|
+
end
|
29
|
+
|
30
|
+
def in_rim_project?
|
31
|
+
find_manifest
|
32
|
+
end
|
33
|
+
|
34
|
+
def chdir_monitor
|
35
|
+
CHDIR_MONITOR
|
36
|
+
end
|
37
|
+
|
38
|
+
def chdir(dir, &blk)
|
39
|
+
chdir_monitor.synchronize do
|
40
|
+
Dir.chdir dir, &blk
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def find_manifest
|
47
|
+
given = ENV['RIM_MANIFEST']
|
48
|
+
return given if given && !given.empty?
|
49
|
+
|
50
|
+
find_file(CONFIG_FILE_NAME)
|
51
|
+
end
|
52
|
+
|
53
|
+
def find_file(*names)
|
54
|
+
search_up(*names) {|filename|
|
55
|
+
return filename if File.file?(filename)
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
59
|
+
def find_directory(*names)
|
60
|
+
search_up(*names) do |dirname|
|
61
|
+
return dirname if File.directory?(dirname)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def search_up(*names)
|
66
|
+
previous = nil
|
67
|
+
current = File.expand_path(Dir.pwd)
|
68
|
+
|
69
|
+
until !File.directory?(current) || current == previous
|
70
|
+
names.each do |name|
|
71
|
+
filename = File.join(current, name)
|
72
|
+
yield filename
|
73
|
+
end
|
74
|
+
current, previous = File.expand_path("..", current), current
|
75
|
+
end
|
76
|
+
end
|
77
|
+
extend self
|
78
|
+
end
|
79
|
+
|
80
|
+
end # Manifest
|
81
|
+
end # RIM
|
82
|
+
|
@@ -1,41 +1,41 @@
|
|
1
|
-
require 'json'
|
2
|
-
require 'csv'
|
3
|
-
require 'rim/manifest/model'
|
4
|
-
|
5
|
-
class RimError < StandardError
|
6
|
-
def self.status_code(code)
|
7
|
-
define_method(:status_code) { code }
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
class ManifestFileNotFound < RimError; status_code(10) ; end
|
12
|
-
|
13
|
-
module RIM
|
14
|
-
module Manifest
|
15
|
-
|
16
|
-
def read_manifest(f)
|
17
|
-
raise "no manifest found" unless f
|
18
|
-
parse_manifest(File.read(f))
|
19
|
-
end
|
20
|
-
|
21
|
-
def parse_manifest(json)
|
22
|
-
data_hash = JSON.parse(json)
|
23
|
-
modules = []
|
24
|
-
if data_hash.has_key?("modules")
|
25
|
-
data_hash["modules"].each do |mod|
|
26
|
-
modules.push(
|
27
|
-
Module.new(
|
28
|
-
:remote_path => mod["remote_path"],
|
29
|
-
:local_path => mod["local_path"],
|
30
|
-
:target_revision => mod["target_revision"],
|
31
|
-
:ignores => mod["ignores"],
|
32
|
-
:subdir => mod["subdir"]
|
33
|
-
))
|
34
|
-
end
|
35
|
-
end
|
36
|
-
Manifest.new(data_hash["remote_url"], modules)
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
1
|
+
require 'json'
|
2
|
+
require 'csv'
|
3
|
+
require 'rim/manifest/model'
|
4
|
+
|
5
|
+
class RimError < StandardError
|
6
|
+
def self.status_code(code)
|
7
|
+
define_method(:status_code) { code }
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class ManifestFileNotFound < RimError; status_code(10) ; end
|
12
|
+
|
13
|
+
module RIM
|
14
|
+
module Manifest
|
15
|
+
|
16
|
+
def read_manifest(f)
|
17
|
+
raise "no manifest found" unless f
|
18
|
+
parse_manifest(File.read(f))
|
19
|
+
end
|
20
|
+
|
21
|
+
def parse_manifest(json)
|
22
|
+
data_hash = JSON.parse(json)
|
23
|
+
modules = []
|
24
|
+
if data_hash.has_key?("modules")
|
25
|
+
data_hash["modules"].each do |mod|
|
26
|
+
modules.push(
|
27
|
+
Module.new(
|
28
|
+
:remote_path => mod["remote_path"],
|
29
|
+
:local_path => mod["local_path"],
|
30
|
+
:target_revision => mod["target_revision"],
|
31
|
+
:ignores => mod["ignores"],
|
32
|
+
:subdir => mod["subdir"]
|
33
|
+
))
|
34
|
+
end
|
35
|
+
end
|
36
|
+
Manifest.new(data_hash["remote_url"], modules)
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
{
|
2
|
-
"remote_url" : "ssh://gerrit",
|
3
|
-
"modules" : [
|
4
|
-
{"local_path": "./bsw/nvStorage", "remote_path": "bsw/modules/nvStorage", "target_revision": "1.1"},
|
5
|
-
{"local_path": "./bsw/eepromManager", "remote_path":"bsw/modules/eepromManager", "target_revision": "1.0"}
|
6
|
-
]
|
7
|
-
}
|
1
|
+
{
|
2
|
+
"remote_url" : "ssh://gerrit",
|
3
|
+
"modules" : [
|
4
|
+
{"local_path": "./bsw/nvStorage", "remote_path": "bsw/modules/nvStorage", "target_revision": "1.1"},
|
5
|
+
{"local_path": "./bsw/eepromManager", "remote_path":"bsw/modules/eepromManager", "target_revision": "1.0"}
|
6
|
+
]
|
7
|
+
}
|
data/lib/rim/module_helper.rb
CHANGED
@@ -1,57 +1,57 @@
|
|
1
|
-
require 'rim/processor'
|
2
|
-
require 'rim/rim_exception'
|
3
|
-
require 'rim/rim_info'
|
4
|
-
require 'rim/file_helper'
|
5
|
-
require 'rim/dirty_check'
|
6
|
-
|
7
|
-
module RIM
|
8
|
-
|
9
|
-
class ModuleHelper < Processor
|
10
|
-
|
11
|
-
attr_reader :module_info
|
12
|
-
|
13
|
-
def initialize(workspace_root, module_info, logger)
|
14
|
-
super(workspace_root, logger)
|
15
|
-
@module_info = module_info
|
16
|
-
@remote_url = get_absolute_remote_url(@module_info.remote_url) if @module_info.remote_url
|
17
|
-
@remote_path = remote_path(@module_info.remote_url) if @module_info.remote_url
|
18
|
-
@logger = logger
|
19
|
-
end
|
20
|
-
|
21
|
-
protected
|
22
|
-
|
23
|
-
# fetch module +mod+ into the .rim folder
|
24
|
-
# works both for initial fetch and updates
|
25
|
-
def fetch_module
|
26
|
-
FileUtils.mkdir_p git_path
|
27
|
-
RIM::git_session(git_path) do |s|
|
28
|
-
if !File.exist?(git_path + "/config")
|
29
|
-
s.execute("git clone --mirror #{@remote_url} #{git_path}") do |out, e|
|
30
|
-
raise RimException.new("Remote repository '#{@remote_url}' of module '#{@module_info.local_path}' not found.") if e
|
31
|
-
end
|
32
|
-
else
|
33
|
-
s.execute("git remote update")
|
34
|
-
end
|
35
|
-
end
|
36
|
-
git_path
|
37
|
-
end
|
38
|
-
|
39
|
-
# prepare empty folder: remove all files not on the ignore list and empty folders
|
40
|
-
def prepare_empty_folder(local_path, ignores)
|
41
|
-
ignores = FileHelper.find_matching_files(local_path, true, ignores)
|
42
|
-
FileHelper.find_matching_files(local_path, true, "/**/*", File::FNM_DOTMATCH).each do |f|
|
43
|
-
if File.file?(f) && !ignores.include?(f)
|
44
|
-
FileUtils.rm(f)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
FileHelper.remove_empty_dirs(local_path)
|
48
|
-
FileUtils.mkdir_p(local_path)
|
49
|
-
end
|
50
|
-
|
51
|
-
def git_path
|
52
|
-
module_git_path(@remote_path)
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
1
|
+
require 'rim/processor'
|
2
|
+
require 'rim/rim_exception'
|
3
|
+
require 'rim/rim_info'
|
4
|
+
require 'rim/file_helper'
|
5
|
+
require 'rim/dirty_check'
|
6
|
+
|
7
|
+
module RIM
|
8
|
+
|
9
|
+
class ModuleHelper < Processor
|
10
|
+
|
11
|
+
attr_reader :module_info
|
12
|
+
|
13
|
+
def initialize(workspace_root, module_info, logger)
|
14
|
+
super(workspace_root, logger)
|
15
|
+
@module_info = module_info
|
16
|
+
@remote_url = get_absolute_remote_url(@module_info.remote_url) if @module_info.remote_url
|
17
|
+
@remote_path = remote_path(@module_info.remote_url) if @module_info.remote_url
|
18
|
+
@logger = logger
|
19
|
+
end
|
20
|
+
|
21
|
+
protected
|
22
|
+
|
23
|
+
# fetch module +mod+ into the .rim folder
|
24
|
+
# works both for initial fetch and updates
|
25
|
+
def fetch_module
|
26
|
+
FileUtils.mkdir_p git_path
|
27
|
+
RIM::git_session(git_path) do |s|
|
28
|
+
if !File.exist?(git_path + "/config")
|
29
|
+
s.execute("git clone --mirror #{@remote_url} #{git_path}") do |out, e|
|
30
|
+
raise RimException.new("Remote repository '#{@remote_url}' of module '#{@module_info.local_path}' not found.") if e
|
31
|
+
end
|
32
|
+
else
|
33
|
+
s.execute("git remote update")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
git_path
|
37
|
+
end
|
38
|
+
|
39
|
+
# prepare empty folder: remove all files not on the ignore list and empty folders
|
40
|
+
def prepare_empty_folder(local_path, ignores)
|
41
|
+
ignores = FileHelper.find_matching_files(local_path, true, ignores)
|
42
|
+
FileHelper.find_matching_files(local_path, true, "/**/*", File::FNM_DOTMATCH).each do |f|
|
43
|
+
if File.file?(f) && !ignores.include?(f)
|
44
|
+
FileUtils.rm(f)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
FileHelper.remove_empty_dirs(local_path)
|
48
|
+
FileUtils.mkdir_p(local_path)
|
49
|
+
end
|
50
|
+
|
51
|
+
def git_path
|
52
|
+
module_git_path(@remote_path)
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
data/lib/rim/module_info.rb
CHANGED
@@ -1,43 +1,43 @@
|
|
1
|
-
module RIM
|
2
|
-
|
3
|
-
class ModuleInfo
|
4
|
-
# remote url (unique identifier of module)
|
5
|
-
attr_reader :remote_url
|
6
|
-
# remote branch format
|
7
|
-
attr_reader :remote_branch_format
|
8
|
-
# locale module path
|
9
|
-
attr_reader :local_path
|
10
|
-
# target revision
|
11
|
-
attr_reader :target_revision
|
12
|
-
# ignores
|
13
|
-
attr_reader :ignores
|
14
|
-
|
15
|
-
attr_reader :subdir
|
16
|
-
|
17
|
-
def initialize(remote_url,
|
18
|
-
local_path,
|
19
|
-
target_revision,
|
20
|
-
ignores = nil,
|
21
|
-
remote_branch_format = nil,
|
22
|
-
subdir = nil)
|
23
|
-
@remote_url = remote_url
|
24
|
-
@remote_branch_format = remote_branch_format
|
25
|
-
@local_path = local_path
|
26
|
-
@target_revision = target_revision
|
27
|
-
@subdir = subdir
|
28
|
-
if ignores.is_a?(String)
|
29
|
-
@ignores = ignores.split(",").each do |s|
|
30
|
-
s.strip!
|
31
|
-
end
|
32
|
-
else
|
33
|
-
@ignores = ignores || []
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def valid?
|
38
|
-
return @remote_url && @local_path && @target_revision
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
1
|
+
module RIM
|
2
|
+
|
3
|
+
class ModuleInfo
|
4
|
+
# remote url (unique identifier of module)
|
5
|
+
attr_reader :remote_url
|
6
|
+
# remote branch format
|
7
|
+
attr_reader :remote_branch_format
|
8
|
+
# locale module path
|
9
|
+
attr_reader :local_path
|
10
|
+
# target revision
|
11
|
+
attr_reader :target_revision
|
12
|
+
# ignores
|
13
|
+
attr_reader :ignores
|
14
|
+
|
15
|
+
attr_reader :subdir
|
16
|
+
|
17
|
+
def initialize(remote_url,
|
18
|
+
local_path,
|
19
|
+
target_revision,
|
20
|
+
ignores = nil,
|
21
|
+
remote_branch_format = nil,
|
22
|
+
subdir = nil)
|
23
|
+
@remote_url = remote_url
|
24
|
+
@remote_branch_format = remote_branch_format
|
25
|
+
@local_path = local_path
|
26
|
+
@target_revision = target_revision
|
27
|
+
@subdir = subdir
|
28
|
+
if ignores.is_a?(String)
|
29
|
+
@ignores = ignores.split(",").each do |s|
|
30
|
+
s.strip!
|
31
|
+
end
|
32
|
+
else
|
33
|
+
@ignores = ignores || []
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def valid?
|
38
|
+
return @remote_url && @local_path && @target_revision
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|