esr-rim 1.3.9 → 1.4.7
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 +20 -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 +26 -2
- data/lib/rim/sync_helper.rb +150 -150
- data/lib/rim/sync_module_helper.rb +107 -106
- 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 -11
data/lib/rim/dirty_check.rb
CHANGED
@@ -61,8 +61,15 @@ class DirtyCheck
|
|
61
61
|
files.delete("..")
|
62
62
|
# ignore the info file itself
|
63
63
|
files.delete(RimInfo::InfoFileName)
|
64
|
-
#
|
65
|
-
|
64
|
+
# ignore all other files
|
65
|
+
# (note: in esr-rim <= 1.42 this was realized by Dir::glob, but this breaks if "dir" is
|
66
|
+
# changed during the check, e.g. by parallel unittest builds
|
67
|
+
# fnIgn is calculated like find_matching_files did it before to avoid problems
|
68
|
+
dirpath = Pathname.new(dir)
|
69
|
+
fnIgn = FileHelper.normalize_patterns(mi.ignores).map do |m|
|
70
|
+
Pathname.new(File.join(dir, m)).relative_path_from(dirpath).to_s
|
71
|
+
end
|
72
|
+
files.delete_if { |f| fnIgn.any?{|m| File.fnmatch(m, f, File::FNM_PATHNAME)} }
|
66
73
|
# order of files makes a difference
|
67
74
|
# sort to eliminate platform specific glob behavior
|
68
75
|
files.sort!
|
data/lib/rim/file_helper.rb
CHANGED
data/lib/rim/git.rb
CHANGED
@@ -98,6 +98,13 @@ class GitSession
|
|
98
98
|
end
|
99
99
|
nil
|
100
100
|
end
|
101
|
+
|
102
|
+
# check whether a commit exists
|
103
|
+
def commit_exists?(sha)
|
104
|
+
execute("git rev-parse --quiet --verify #{sha}^{commit}") do |b, e|
|
105
|
+
return !e
|
106
|
+
end
|
107
|
+
end
|
101
108
|
|
102
109
|
# check whether branch exists
|
103
110
|
def has_branch?(branch)
|
@@ -144,6 +151,17 @@ class GitSession
|
|
144
151
|
end
|
145
152
|
sha1
|
146
153
|
end
|
154
|
+
|
155
|
+
# returns some informations about a revision
|
156
|
+
def rev_infos(rev, desired)
|
157
|
+
info = {}
|
158
|
+
desired.each_pair do |key, value|
|
159
|
+
execute "git log -1 --format=#{value} #{rev} --" do |out, e|
|
160
|
+
info[key] = out.strip if !e
|
161
|
+
end
|
162
|
+
end
|
163
|
+
info
|
164
|
+
end
|
147
165
|
|
148
166
|
# returns the SHA-1 representations of the heads of all remote branches
|
149
167
|
def remote_branch_revs
|
@@ -179,7 +197,7 @@ class GitSession
|
|
179
197
|
path_args << " "
|
180
198
|
path_args << paths.shift
|
181
199
|
end
|
182
|
-
execute "git archive --format tar #{rev} #{path_args} | tar -
|
200
|
+
execute "git archive --format tar #{rev} #{path_args} | tar -C #{dir} -xf -"
|
183
201
|
break if paths.empty?
|
184
202
|
end
|
185
203
|
end
|
@@ -189,6 +207,7 @@ class GitSession
|
|
189
207
|
# returns the value returned by the block
|
190
208
|
def within_exported_rev(rev, paths=[])
|
191
209
|
Dir.mktmpdir("rim") do |d|
|
210
|
+
d = Dir.glob(d)[0]
|
192
211
|
c = File.join(d, "content")
|
193
212
|
FileUtils.mkdir(c)
|
194
213
|
export_rev(rev, c, paths)
|
data/lib/rim/info_helper.rb
CHANGED
@@ -23,7 +23,11 @@ class InfoHelper < CommandHelper
|
|
23
23
|
@module_helpers.each do |h|
|
24
24
|
path = h.module_info.local_path.split(/[\\\/]/).last.ljust(40)
|
25
25
|
info = "#{path}: ->#{h.target_rev.ljust(10)} @#{h.current_sha1[0..6]}"
|
26
|
-
|
26
|
+
|
27
|
+
if (!h.current_commit_exists)
|
28
|
+
info += " [COMMIT NOT FOUND]"
|
29
|
+
@logger.info(info)
|
30
|
+
elsif h.upstream_revs
|
27
31
|
if h.upstream_revs.size > 0
|
28
32
|
info += " [#{h.upstream_revs.size} commits behind]"
|
29
33
|
else
|
@@ -5,6 +5,7 @@ module RIM
|
|
5
5
|
class InfoModuleHelper < ModuleHelper
|
6
6
|
|
7
7
|
attr_accessor :target_rev
|
8
|
+
attr_accessor :current_commit_exists
|
8
9
|
attr_accessor :current_sha1
|
9
10
|
attr_accessor :upstream_revs
|
10
11
|
attr_accessor :upstream_non_fast_forward
|
@@ -19,6 +20,10 @@ class InfoModuleHelper < ModuleHelper
|
|
19
20
|
@target_rev = rim_info.target_revision
|
20
21
|
@current_sha1 = rim_info.revision_sha1
|
21
22
|
RIM::git_session(git_path) do |s|
|
23
|
+
if s.commit_exists?(current_sha1)
|
24
|
+
@current_commit_exists = true
|
25
|
+
end
|
26
|
+
|
22
27
|
if s.has_remote_branch?(target_rev)
|
23
28
|
# repository is mirrored so branches are "local"
|
24
29
|
if s.is_ancestor?(current_sha1, target_rev)
|
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
|