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.
@@ -61,8 +61,15 @@ class DirtyCheck
61
61
  files.delete("..")
62
62
  # ignore the info file itself
63
63
  files.delete(RimInfo::InfoFileName)
64
- # ignores defined by user
65
- files -= FileHelper.find_matching_files(dir, false, mi.ignores)
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!
@@ -40,8 +40,6 @@ class FileHelper
40
40
  FileUtils.mkdir_p(dir)
41
41
  end
42
42
 
43
- private
44
-
45
43
  def self.normalize_patterns(patterns = [])
46
44
  if patterns.is_a?(String)
47
45
  return patterns.split(",").each do |p|
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)
@@ -190,7 +197,7 @@ class GitSession
190
197
  path_args << " "
191
198
  path_args << paths.shift
192
199
  end
193
- execute "git archive --format tar #{rev} #{path_args} | tar -x -C #{dir}"
200
+ execute "git archive --format tar #{rev} #{path_args} | tar -C #{dir} -xf -"
194
201
  break if paths.empty?
195
202
  end
196
203
  end
@@ -200,6 +207,7 @@ class GitSession
200
207
  # returns the value returned by the block
201
208
  def within_exported_rev(rev, paths=[])
202
209
  Dir.mktmpdir("rim") do |d|
210
+ d = Dir.glob(d)[0]
203
211
  c = File.join(d, "content")
204
212
  FileUtils.mkdir(c)
205
213
  export_rev(rev, c, paths)
@@ -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
- if h.upstream_revs
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)
@@ -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
+ }
@@ -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