git-multirepo 1.0.0.beta47 → 1.0.0.beta48

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.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.multirepo.meta +1 -1
  3. data/.rubocop.yml +79 -0
  4. data/Rakefile +0 -1
  5. data/bin/multi +1 -1
  6. data/git-multirepo.gemspec +1 -1
  7. data/lib/commands.rb +1 -1
  8. data/lib/git-multirepo.rb +1 -1
  9. data/lib/info.rb +2 -2
  10. data/lib/multirepo/commands/add-command.rb +4 -4
  11. data/lib/multirepo/commands/branch-command.rb +8 -8
  12. data/lib/multirepo/commands/checkout-command.rb +7 -7
  13. data/lib/multirepo/commands/clone-command.rb +6 -6
  14. data/lib/multirepo/commands/command.rb +9 -9
  15. data/lib/multirepo/commands/do-command.rb +3 -3
  16. data/lib/multirepo/commands/graph-command.rb +1 -1
  17. data/lib/multirepo/commands/init-command.rb +14 -13
  18. data/lib/multirepo/commands/inspect-command.rb +2 -2
  19. data/lib/multirepo/commands/install-command.rb +5 -5
  20. data/lib/multirepo/commands/merge-command.rb +11 -12
  21. data/lib/multirepo/commands/open-command.rb +1 -1
  22. data/lib/multirepo/commands/remove-command.rb +2 -2
  23. data/lib/multirepo/commands/uninit-command.rb +1 -1
  24. data/lib/multirepo/commands/update-command.rb +21 -11
  25. data/lib/multirepo/config.rb +1 -1
  26. data/lib/multirepo/files/config-entry.rb +5 -5
  27. data/lib/multirepo/files/config-file.rb +2 -2
  28. data/lib/multirepo/files/lock-entry.rb +1 -1
  29. data/lib/multirepo/files/lock-file.rb +2 -2
  30. data/lib/multirepo/files/meta-file.rb +1 -1
  31. data/lib/multirepo/files/tracking-file.rb +2 -2
  32. data/lib/multirepo/files/tracking-files.rb +1 -1
  33. data/lib/multirepo/git/branch.rb +2 -2
  34. data/lib/multirepo/git/change.rb +1 -1
  35. data/lib/multirepo/git/commit.rb +1 -1
  36. data/lib/multirepo/git/git-runner.rb +2 -4
  37. data/lib/multirepo/git/git.rb +1 -1
  38. data/lib/multirepo/git/ref.rb +2 -2
  39. data/lib/multirepo/git/remote.rb +1 -1
  40. data/lib/multirepo/git/repo.rb +6 -6
  41. data/lib/multirepo/hooks/post-commit-hook.rb +1 -1
  42. data/lib/multirepo/hooks/pre-commit-hook.rb +1 -1
  43. data/lib/multirepo/logic/dependency.rb +1 -1
  44. data/lib/multirepo/logic/merge-descriptor.rb +11 -11
  45. data/lib/multirepo/logic/node.rb +9 -9
  46. data/lib/multirepo/logic/performer.rb +6 -8
  47. data/lib/multirepo/logic/revision-selector.rb +9 -9
  48. data/lib/multirepo/multirepo-exception.rb +1 -1
  49. data/lib/multirepo/utility/console.rb +2 -2
  50. data/lib/multirepo/utility/popen-runner.rb +2 -2
  51. data/lib/multirepo/utility/system-runner.rb +1 -1
  52. data/lib/multirepo/utility/utils.rb +15 -15
  53. data/lib/multirepo/utility/verbosity.rb +1 -1
  54. data/resources/post-commit +1 -1
  55. data/resources/pre-commit +1 -1
  56. data/spec/integration/init_spec.rb +1 -1
  57. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4049f70b0eb447de770ad97c5a0f48a834be84ce
4
- data.tar.gz: 3e4de942d39a715163954ad0e194499d8eac5102
3
+ metadata.gz: b62e381f56fa28e1019ec5ee90f527e3d6c0caf9
4
+ data.tar.gz: c3a9718b7a7bf951b3c7ff3e7f4b41e80c010a0e
5
5
  SHA512:
6
- metadata.gz: 21db70176b2b8adfc1750c1b823961e12bd6aabd20d5faa9913d1d83326ecc2ce4b162889258fa7d08925a890b13dc015bb3cd4e048044e6959c330e47dac610
7
- data.tar.gz: e7811eac91c7ca9bda47968158ec1e3ac1a6ae02f3e5c82713caf4e5a851e8b7216dbd4f108378d9702f5280c66cc9564dbd182af862cd2055aa0362422e3903
6
+ metadata.gz: e0595de8789ec53bccb911f904a5f86ab53530f15db76b2986ffb14f11dd2a150912d063cb191573eb760ff0a98191dcd1d90ff6befd813f25df0de54ea2db6e
7
+ data.tar.gz: 7c97e0eba324fee9bead97e3928919986b94575103b8aacb5fa885080062a114c1d2da18e5094af254af97f775296d72a4af043d918c0b62202f9aece2e8c534
data/.multirepo.meta CHANGED
@@ -1,2 +1,2 @@
1
1
  --- !ruby/object:MultiRepo::MetaFile
2
- version: 1.0.0.beta46
2
+ version: 1.0.0.beta47
data/.rubocop.yml ADDED
@@ -0,0 +1,79 @@
1
+ # This is the configuration used to check the rubocop source code.
2
+
3
+ AllCops:
4
+ DisplayCopNames: true
5
+ Exclude:
6
+ - 'resources/*'
7
+ - 'pkg/*'
8
+ - 'docs/*'
9
+ - 'spec/spec_helper.rb'
10
+ - 'spec/fixtures/**/*'
11
+
12
+ Style/RescueModifier:
13
+ Enabled: false
14
+
15
+ Lint/EndAlignment:
16
+ Enabled: false
17
+
18
+ Metrics/MethodLength:
19
+ Enabled: false
20
+
21
+ Metrics/LineLength:
22
+ Enabled: false
23
+
24
+ Style/EachWithObject:
25
+ Enabled: false
26
+
27
+ Style/Documentation:
28
+ Enabled: false
29
+
30
+ Style/GuardClause:
31
+ Enabled: false
32
+
33
+ Style/RedundantReturn:
34
+ Enabled: false
35
+
36
+ Style/SpaceBeforeBlockBraces:
37
+ Enabled: false
38
+
39
+ Style/StringLiterals:
40
+ Enabled: false
41
+
42
+ Style/TrailingWhitespace:
43
+ Enabled: false
44
+
45
+ Metrics/AbcSize:
46
+ Enabled: false
47
+
48
+ Metrics/ClassLength:
49
+ Enabled: false
50
+
51
+ Style/ElseAlignment:
52
+ Enabled: false
53
+
54
+ Style/HashSyntax:
55
+ Enabled: false
56
+
57
+ Style/MultilineOperationIndentation:
58
+ Enabled: false
59
+
60
+ Style/Semicolon:
61
+ AllowAsExpressionSeparator: true
62
+
63
+ Style/IndentationWidth:
64
+ Enabled: false
65
+
66
+ Style/SingleLineBlockParams:
67
+ Enabled: false
68
+
69
+ Metrics/CyclomaticComplexity:
70
+ Max: 10
71
+
72
+ Metrics/PerceivedComplexity:
73
+ Max: 8
74
+
75
+ Style/FileName:
76
+ Enabled: false
77
+
78
+ Style/SpecialGlobalVars:
79
+ Enabled: false
data/Rakefile CHANGED
@@ -1,2 +1 @@
1
1
  require "bundler/gem_tasks"
2
-
data/bin/multi CHANGED
@@ -8,4 +8,4 @@ trap("INT") do
8
8
  exit
9
9
  end
10
10
 
11
- MultiRepo::Command.run(ARGV)
11
+ MultiRepo::Command.run(ARGV)
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.version = MultiRepo::VERSION
9
9
  spec.authors = ["Michaël Fortin"]
10
10
  spec.email = ["fortinmike@irradiated.net"]
11
- spec.summary = %q{Track multiple Git repositories side-by-side}
11
+ spec.summary = "Track multiple Git repositories side-by-side"
12
12
  spec.description = MultiRepo::DESCRIPTION
13
13
  spec.homepage = "https://github.com/fortinmike/git-multirepo"
14
14
  spec.license = "MIT"
data/lib/commands.rb CHANGED
@@ -12,4 +12,4 @@ require_relative "multirepo/commands/merge-command"
12
12
  require_relative "multirepo/commands/open-command"
13
13
  require_relative "multirepo/commands/remove-command"
14
14
  require_relative "multirepo/commands/uninit-command"
15
- require_relative "multirepo/commands/update-command"
15
+ require_relative "multirepo/commands/update-command"
data/lib/git-multirepo.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  require "multirepo/utility/console"
2
2
  require "multirepo/hooks/pre-commit-hook"
3
- require "multirepo/hooks/post-commit-hook"
3
+ require "multirepo/hooks/post-commit-hook"
data/lib/info.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module MultiRepo
2
2
  NAME = "git-multirepo"
3
- VERSION = "1.0.0.beta47"
3
+ VERSION = "1.0.0.beta48"
4
4
  DESCRIPTION = "Track multiple Git repositories side-by-side."
5
- end
5
+ end
@@ -37,9 +37,9 @@ module MultiRepo
37
37
  end
38
38
 
39
39
  def ensure_repo_valid
40
- raise MultiRepoException, "The provided path is not a direct sibling of the main repository" unless validate_is_sibling_repo(@path)
41
- raise MultiRepoException, "There is no folder at path '#{@path}'" unless Dir.exists?(@path)
42
- raise MultiRepoException, "'#{@path}' is not a repository" unless Repo.new(@path).exists?
40
+ fail MultiRepoException, "The provided path is not a direct sibling of the main repository" unless validate_is_sibling_repo(@path)
41
+ fail MultiRepoException, "There is no folder at path '#{@path}'" unless Dir.exist?(@path)
42
+ fail MultiRepoException, "'#{@path}' is not a repository" unless Repo.new(@path).exists?
43
43
  end
44
44
 
45
45
  def validate_is_sibling_repo(path)
@@ -48,4 +48,4 @@ module MultiRepo
48
48
  return parent_dir == path
49
49
  end
50
50
  end
51
- end
51
+ end
@@ -39,12 +39,12 @@ module MultiRepo
39
39
  main_repo = Repo.new(".")
40
40
 
41
41
  # Ensure the main repo is clean
42
- raise MultiRepoException, "Main repo is not clean; multi branch aborted" unless main_repo.clean?
42
+ fail MultiRepoException, "Main repo is not clean; multi branch aborted" unless main_repo.clean?
43
43
 
44
44
  # Ensure dependencies are clean
45
45
  config_entries = ConfigFile.new(".").load_entries
46
46
  unless Utils.dependencies_clean?(config_entries)
47
- raise MultiRepoException, "Dependencies are not clean; multi branch aborted"
47
+ fail MultiRepoException, "Dependencies are not clean; multi branch aborted"
48
48
  end
49
49
 
50
50
  # Branch dependencies
@@ -66,17 +66,17 @@ module MultiRepo
66
66
  branch.create unless branch.exists?
67
67
  branch.checkout
68
68
 
69
- if Utils.is_multirepo_enabled(repo.path)
69
+ if Utils.multirepo_enabled?(repo.path)
70
70
  Console.log_info("Updating and committing tracking files")
71
71
  tracking_files = TrackingFiles.new(repo.path)
72
72
  tracking_files.update
73
73
  tracking_files.commit("[multirepo] Post-branch tracking files update")
74
74
  end
75
75
 
76
- if @remote_tracking
77
- Console.log_info("Pushing #{@branch_name} to origin/#{@branch_name}")
78
- repo.branch(@branch_name).push
79
- end
76
+ return unless @remote_tracking
77
+
78
+ Console.log_info("Pushing #{@branch_name} to origin/#{@branch_name}")
79
+ repo.branch(@branch_name).push
80
80
  end
81
81
  end
82
- end
82
+ end
@@ -42,7 +42,7 @@ module MultiRepo
42
42
  main_repo = Repo.new(".")
43
43
 
44
44
  unless proceed_if_merge_commit?(main_repo, @ref_name, mode)
45
- raise MultiRepoException, "Aborting checkout"
45
+ fail MultiRepoException, "Aborting checkout"
46
46
  end
47
47
 
48
48
  checkout_core(main_repo, mode)
@@ -56,7 +56,7 @@ module MultiRepo
56
56
  # Checkout first because the current ref might not be multirepo-enabled
57
57
  checkout_main_repo_step(main_repo)
58
58
  # Only then can we check for dependencies and make sure they are clean
59
- ensure_dependencies_clean_step(main_repo)
59
+ ensure_dependencies_clean_step
60
60
  rescue MultiRepoException => e
61
61
  Console.log_warning("Restoring working copy to #{initial_revision}")
62
62
  main_repo.checkout(initial_revision)
@@ -69,9 +69,9 @@ module MultiRepo
69
69
  Performer.perform_main_repo_checkout(main_repo, @ref_name)
70
70
  end
71
71
 
72
- def ensure_dependencies_clean_step(main_repo)
72
+ def ensure_dependencies_clean_step
73
73
  unless Utils.dependencies_clean?(ConfigFile.new(".").load_entries)
74
- raise MultiRepoException, "Dependencies are not clean!"
74
+ fail MultiRepoException, "Dependencies are not clean!"
75
75
  end
76
76
  end
77
77
 
@@ -84,7 +84,7 @@ module MultiRepo
84
84
  end
85
85
 
86
86
  def proceed_if_merge_commit?(main_repo, ref_name, mode)
87
- return true unless main_repo.ref(ref_name).is_merge?
87
+ return true unless main_repo.ref(ref_name).merge_commit?
88
88
 
89
89
  case mode
90
90
  when RevisionSelectionMode::AS_LOCK
@@ -113,8 +113,8 @@ module MultiRepo
113
113
  if config_entry.repo.checkout(revision)
114
114
  Console.log_substep("Checked out #{dependency_name} '#{revision}'")
115
115
  else
116
- raise MultiRepoException, "Couldn't check out the appropriate version of dependency #{dependency_name}"
116
+ fail MultiRepoException, "Couldn't check out the appropriate version of dependency #{dependency_name}"
117
117
  end
118
118
  end
119
119
  end
120
- end
120
+ end
@@ -32,7 +32,7 @@ module MultiRepo
32
32
  def run
33
33
  Console.log_step("Cloning #{@url} ...")
34
34
 
35
- raise MultiRepoException, "A directory named #{@name} already exists" if Dir.exists?(@name)
35
+ fail MultiRepoException, "A directory named #{@name} already exists" if Dir.exist?(@name)
36
36
 
37
37
  main_repo_path = "#{@name}/#{@name}"
38
38
  main_repo = Repo.new(main_repo_path)
@@ -41,18 +41,18 @@ module MultiRepo
41
41
  FileUtils.mkpath(main_repo_path)
42
42
 
43
43
  # Clone the specified remote in the just-created directory
44
- raise MultiRepoException, "Could not clone repo from #{@url}" unless main_repo.clone(@url)
44
+ fail MultiRepoException, "Could not clone repo from #{@url}" unless main_repo.clone(@url)
45
45
 
46
46
  # Checkout the specified main repo ref so that install reads the proper config file
47
47
  unless main_repo.checkout(@ref_name)
48
- raise MultiRepoException, "Couldn't perform checkout of main repo #{@ref_name}!"
48
+ fail MultiRepoException, "Couldn't perform checkout of main repo #{@ref_name}!"
49
49
  end
50
50
 
51
51
  Console.log_substep("Checked out main repo #{@ref_name}")
52
52
 
53
53
  # Make sure the ref we just checked out is tracked by multirepo
54
- unless Utils.is_multirepo_tracked(main_repo_path)
55
- raise MultiRepoException, "Ref #{@ref_name} is not tracked by multirepo"
54
+ unless Utils.multirepo_tracked?(main_repo_path)
55
+ fail MultiRepoException, "Ref #{@ref_name} is not tracked by multirepo"
56
56
  end
57
57
 
58
58
  # Install
@@ -65,4 +65,4 @@ module MultiRepo
65
65
  Console.log_step("Done!")
66
66
  end
67
67
  end
68
- end
68
+ end
@@ -18,7 +18,7 @@ module MultiRepo
18
18
  Console.log_error(exception.message)
19
19
  exit 1
20
20
  end
21
- raise exception
21
+ fail exception
22
22
  end
23
23
 
24
24
  def initialize(argv)
@@ -36,7 +36,7 @@ module MultiRepo
36
36
  super
37
37
  path = Config.instance.git_executable
38
38
  is_git_exe = path =~ /.*(git)|(git.exe)$/
39
- file_exists = path == "git" || File.exists?(path)
39
+ file_exists = path == "git" || File.exist?(path)
40
40
  help! "Invalid git executable '#{path}'" unless is_git_exe && file_exists
41
41
  end
42
42
 
@@ -63,7 +63,7 @@ module MultiRepo
63
63
  end
64
64
 
65
65
  def multirepo_enabled_dependencies
66
- ConfigFile.new(".").load_entries.select { |e| Utils.is_multirepo_enabled(e.repo.path) }
66
+ ConfigFile.new(".").load_entries.select { |e| Utils.multirepo_enabled?(e.repo.path) }
67
67
  end
68
68
 
69
69
  def validate_only_one_flag(*flags)
@@ -72,19 +72,19 @@ module MultiRepo
72
72
 
73
73
  def ensure_in_work_tree
74
74
  repo = Repo.new(".")
75
- raise MultiRepoException, "Not a git repository" unless repo.exists?
76
- raise MultiRepoException, "HEAD is unborn (you must perform at least one commit)" unless repo.head_born?
75
+ fail MultiRepoException, "Not a git repository" unless repo.exists?
76
+ fail MultiRepoException, "HEAD is unborn (you must perform at least one commit)" unless repo.head_born?
77
77
  end
78
78
 
79
79
  def ensure_multirepo_enabled
80
- raise MultiRepoException, "multirepo is not initialized in this repository." unless Utils.is_multirepo_enabled(".")
80
+ fail MultiRepoException, "multirepo is not initialized in this repository." unless Utils.multirepo_enabled?(".")
81
81
  end
82
82
 
83
83
  def ensure_multirepo_tracked
84
- raise MultiRepoException, "Revision is not tracked by multirepo." unless Utils.is_multirepo_tracked(".")
84
+ fail MultiRepoException, "Revision is not tracked by multirepo." unless Utils.multirepo_tracked?(".")
85
85
 
86
86
  lock_file_valid = LockFile.new(".").validate!
87
- raise MultiRepoException, "Revision is multirepo-enabled but contains a corrupted lock file!" unless lock_file_valid
87
+ fail MultiRepoException, "Revision is multirepo-enabled but contains a corrupted lock file!" unless lock_file_valid
88
88
  end
89
89
  end
90
- end
90
+ end
@@ -80,14 +80,14 @@ module MultiRepo
80
80
  def confirm_main_repo_operation
81
81
  unless main_repo_clean?
82
82
  Console.log_warning("Main repo contains uncommitted changes")
83
- raise MultiRepoException, "Aborted" unless Console.ask_yes_no("Proceed anyway?")
83
+ fail MultiRepoException, "Aborted" unless Console.ask_yes_no("Proceed anyway?")
84
84
  end
85
85
  end
86
86
 
87
87
  def confirm_dependencies_operation
88
88
  unless dependencies_clean?
89
89
  Console.log_warning("Some dependencies contain uncommitted changes")
90
- raise MultiRepoException, "Aborted" unless Console.ask_yes_no("Proceed anyway?")
90
+ fail MultiRepoException, "Aborted" unless Console.ask_yes_no("Proceed anyway?")
91
91
  end
92
92
  end
93
93
 
@@ -100,4 +100,4 @@ module MultiRepo
100
100
  return Utils.dependencies_clean?(config_entries)
101
101
  end
102
102
  end
103
- end
103
+ end
@@ -40,4 +40,4 @@ module MultiRepo
40
40
  end
41
41
  end
42
42
  end
43
- end
43
+ end
@@ -37,11 +37,11 @@ module MultiRepo
37
37
  def full_initialize_step
38
38
  if ConfigFile.new(".").exists?
39
39
  reinitialize = Console.ask_yes_no(".multirepo file already exists. Reinitialize?")
40
- raise MultiRepoException, "Initialization aborted" unless reinitialize
40
+ fail MultiRepoException, "Initialization aborted" unless reinitialize
41
41
  end
42
42
 
43
43
  unless add_sibling_repos_step
44
- raise MultiRepoException, "There are no sibling repositories to track as dependencies. Initialization aborted."
44
+ fail MultiRepoException, "There are no sibling repositories to track as dependencies. Initialization aborted."
45
45
  end
46
46
 
47
47
  initialize_extras_step
@@ -56,7 +56,7 @@ module MultiRepo
56
56
  valid_repos = find_valid_repos(sibling_repos)
57
57
  entries = create_entries(valid_repos)
58
58
 
59
- raise MultiRepoException, "No sibling repositories were added as dependencies; init aborted" unless entries.any?
59
+ fail MultiRepoException, "No sibling repositories were added as dependencies; init aborted" unless entries.any?
60
60
 
61
61
  ConfigFile.new(".").save_entries(entries)
62
62
  return true
@@ -100,21 +100,22 @@ module MultiRepo
100
100
  origin_url = repo.remote('origin').url
101
101
  current_branch_name = repo.current_branch.name
102
102
 
103
- if Console.ask_yes_no("Do you want to add '#{repo.path}' as a dependency?\n [origin: #{origin_url || "NONE"}, branch: #{current_branch_name}]")
104
- unless origin_url
105
- Console.log_warning("Repo 'origin' remote url is not set; skipping")
106
- next
107
- end
108
- entries.push(ConfigEntry.new(repo))
109
- Console.log_substep("Added the repository '#{repo.path}' to the .multirepo file")
103
+ next unless Console.ask_yes_no("Do you want to add '#{repo.path}' as a dependency?\n [origin: #{origin_url || 'NONE'}, branch: #{current_branch_name}]")
104
+
105
+ unless origin_url
106
+ Console.log_warning("Repo 'origin' remote url is not set; skipping")
107
+ next
110
108
  end
109
+
110
+ entries.push(ConfigEntry.new(repo))
111
+ Console.log_substep("Added the repository '#{repo.path}' to the .multirepo file")
111
112
  end
112
113
  return entries
113
114
  end
114
115
 
115
116
  def check_repo_exists
116
- raise MultiRepoException, "There is no folder at path '#{@repo.path}'" unless Dir.exists?(@repo.path)
117
- raise MultiRepoException, "'#{@repo.path}' is not a repository" unless @repo.exists?
117
+ fail MultiRepoException, "There is no folder at path '#{@repo.path}'" unless Dir.exist?(@repo.path)
118
+ fail MultiRepoException, "'#{@repo.path}' is not a repository" unless @repo.exists?
118
119
  end
119
120
  end
120
- end
121
+ end
@@ -32,8 +32,8 @@ module MultiRepo
32
32
  if @version
33
33
  puts MetaFile.new(".").load.version
34
34
  elsif @tracked
35
- puts Utils.is_multirepo_tracked(".").to_s
35
+ puts Utils.multirepo_tracked?(".").to_s
36
36
  end
37
37
  end
38
38
  end
39
- end
39
+ end
@@ -82,7 +82,7 @@ module MultiRepo
82
82
  def install_dependencies_step
83
83
  # Read config entries as-is on disk, without prior checkout
84
84
  config_entries = ConfigFile.new(".").load_entries
85
- Console.log_substep("Installing #{config_entries.count} dependencies...");
85
+ Console.log_substep("Installing #{config_entries.count} dependencies...")
86
86
 
87
87
  # Clone or fetch all configured dependencies to make sure nothing is missing locally
88
88
  Performer.dependencies.each { |d| clone_or_fetch(d) }
@@ -127,13 +127,13 @@ module MultiRepo
127
127
 
128
128
  def fetch_repo(dependency)
129
129
  unless dependency.config_entry.repo.fetch
130
- raise MultiRepoException, "Could not fetch from remote #{dependency.config_entry.repo.remote('origin').url}"
130
+ fail MultiRepoException, "Could not fetch from remote #{dependency.config_entry.repo.remote('origin').url}"
131
131
  end
132
132
  end
133
133
 
134
134
  def clone_repo(dependency)
135
135
  unless dependency.config_entry.repo.clone(dependency.config_entry.url, dependency.lock_entry.branch)
136
- raise MultiRepoException, "Could not clone remote #{dependency.config_entry.url} with branch #{dependency.config_entry.branch}"
136
+ fail MultiRepoException, "Could not clone remote #{dependency.config_entry.url} with branch #{dependency.config_entry.branch}"
137
137
  end
138
138
  end
139
139
 
@@ -141,8 +141,8 @@ module MultiRepo
141
141
 
142
142
  def check_repo_validity(dependency)
143
143
  unless dependency.config_entry.repo.remote("origin").url == dependency.config_entry.url
144
- raise MultiRepoException, "'#{dependency.config_entry.path}' origin URL (#{dependency.config_entry.repo.remote('origin').url}) does not match entry (#{dependency.config_entry.url})!"
144
+ fail MultiRepoException, "'#{dependency.config_entry.path}' origin URL (#{dependency.config_entry.repo.remote('origin').url}) does not match entry (#{dependency.config_entry.url})!"
145
145
  end
146
146
  end
147
147
  end
148
- end
148
+ end
@@ -74,14 +74,13 @@ module MultiRepo
74
74
 
75
75
  def merge_core(main_repo, initial_revision, mode)
76
76
  config_file = ConfigFile.new(".")
77
- lock_file = LockFile.new(".")
78
77
 
79
78
  # Ensure the main repo is clean
80
- raise MultiRepoException, "Main repo is not clean; merge aborted" unless main_repo.clean?
79
+ fail MultiRepoException, "Main repo is not clean; merge aborted" unless main_repo.clean?
81
80
 
82
81
  # Ensure dependencies are clean
83
82
  unless Utils.dependencies_clean?(config_file.load_entries)
84
- raise MultiRepoException, "Dependencies are not clean; merge aborted"
83
+ fail MultiRepoException, "Dependencies are not clean; merge aborted"
85
84
  end
86
85
 
87
86
  ref_name = @ref_name
@@ -98,20 +97,20 @@ module MultiRepo
98
97
 
99
98
  case result.outcome
100
99
  when MergeValidationResult::ABORT
101
- raise MultiRepoException, result.message
100
+ fail MultiRepoException, result.message
102
101
  when MergeValidationResult::PROCEED
103
- raise MultiRepoException, "Merge aborted" unless Console.ask_yes_no("Proceed?")
102
+ fail MultiRepoException, "Merge aborted" unless Console.ask_yes_no("Proceed?")
104
103
  Console.log_warning(result.message) if result.message
105
104
  break
106
105
  when MergeValidationResult::MERGE_UPSTREAM
107
106
  Console.log_warning(result.message)
108
- raise MultiRepoException, "Merge aborted" unless Console.ask_yes_no("Merge upstream instead of local branches?")
107
+ fail MultiRepoException, "Merge aborted" unless Console.ask_yes_no("Merge upstream instead of local branches?")
109
108
  # TODO: Modify operations!
110
- raise MultiRepoException, "Fallback behavior not implemented. Please merge manually."
109
+ fail MultiRepoException, "Fallback behavior not implemented. Please merge manually."
111
110
  next
112
111
  end
113
112
 
114
- raise MultiRepoException, "Merge aborted" unless Console.ask_yes_no("Proceed?")
113
+ fail MultiRepoException, "Merge aborted" unless Console.ask_yes_no("Proceed?")
115
114
  end
116
115
 
117
116
  Console.log_step("Performing merge...")
@@ -163,13 +162,13 @@ module MultiRepo
163
162
 
164
163
  def ensure_dependencies_match(our_dependencies, their_dependencies)
165
164
  our_dependencies.zip(their_dependencies).each do |our_dependency, their_dependency|
166
- if their_dependency == nil || their_dependency.config_entry.id != our_dependency.config_entry.id
167
- raise MultiRepoException, "Dependencies differ, please merge manually"
165
+ if their_dependency.nil? || their_dependency.config_entry.id != our_dependency.config_entry.id
166
+ fail MultiRepoException, "Dependencies differ, please merge manually"
168
167
  end
169
168
  end
170
169
 
171
170
  if their_dependencies.count > our_dependencies.count
172
- raise MultiRepoException, "There are more dependencies in the specified ref, please merge manually"
171
+ fail MultiRepoException, "There are more dependencies in the specified ref, please merge manually"
173
172
  end
174
173
  end
175
174
 
@@ -223,4 +222,4 @@ module MultiRepo
223
222
  end
224
223
  end
225
224
  end
226
- end
225
+ end
@@ -54,4 +54,4 @@ module MultiRepo
54
54
  end
55
55
  end
56
56
  end
57
- end
57
+ end
@@ -41,8 +41,8 @@ module MultiRepo
41
41
  Console.log_step("Deleted '#{@path}' from disk")
42
42
  end
43
43
  else
44
- raise MultiRepoException, "'#{@path}' isn't tracked by multirepo"
44
+ fail MultiRepoException, "'#{@path}' isn't tracked by multirepo"
45
45
  end
46
46
  end
47
47
  end
48
- end
48
+ end
@@ -15,4 +15,4 @@ module MultiRepo
15
15
  Console.log_step("All traces of multirepo have been removed from this repository")
16
16
  end
17
17
  end
18
- end
18
+ end
@@ -1,4 +1,5 @@
1
1
  require "multirepo/utility/console"
2
+ require "multirepo/logic/performer"
2
3
  require "multirepo/files/tracking-files"
3
4
 
4
5
  module MultiRepo
@@ -26,31 +27,40 @@ module MultiRepo
26
27
  Console.log_step("Updating...")
27
28
 
28
29
  dependencies_clean = Utils.dependencies_clean?(ConfigFile.new(".").load_entries)
29
- if dependencies_clean
30
- update_lock_file_step("Updated tracking files")
31
- elsif !dependencies_clean && @force
32
- update_lock_file_step("Force-updated tracking files (ignoring uncommitted changes)")
30
+ if dependencies_clean || @force
31
+ update_tracking_files_step
33
32
  else
34
- raise MultiRepoException, "Can't update because not all dependencies are clean"
33
+ fail MultiRepoException, "Can't update because not all dependencies are clean"
35
34
  end
36
35
 
37
36
  Console.log_step("Done!")
38
37
  end
39
38
 
40
- def update_lock_file_step(log_message)
41
- tracking_files = TrackingFiles.new(".")
39
+ def update_tracking_files_step
40
+ Performer.dependencies.each do |dependency|
41
+ path = dependency.config_entry.path
42
+ name = dependency.config_entry.name
43
+ update_tracking_files(path, name) if Utils.multirepo_enabled?(path)
44
+ end
45
+ update_tracking_files(".", "main repo")
46
+ end
47
+
48
+ def update_tracking_files(path, name)
49
+ Console.log_substep("Updating tracking files in #{name}")
50
+
51
+ tracking_files = TrackingFiles.new(path)
42
52
  changed = tracking_files.update
43
53
 
44
54
  if changed
45
- Console.log_substep("Updated tracking files")
55
+ Console.log_info("Updated tracking files")
46
56
  else
47
- Console.log_substep("Tracking files are already up-to-date")
57
+ Console.log_info("Tracking files are already up-to-date")
48
58
  end
49
59
 
50
60
  if @commit
51
61
  committed = tracking_files.commit("[multirepo] Updated tracking files manually")
52
- Console.log_substep("Committed tracking files") if committed
62
+ Console.log_info("Committed tracking files") if committed
53
63
  end
54
64
  end
55
65
  end
56
- end
66
+ end
@@ -13,4 +13,4 @@ module MultiRepo
13
13
  attr_accessor :git_executable
14
14
  @git_executable = nil
15
15
  end
16
- end
16
+ end
@@ -22,10 +22,10 @@ module MultiRepo
22
22
  @url = repo.exists? ? repo.remote('origin').url : nil
23
23
  end
24
24
 
25
- def ==(entry)
26
- entry_path = Pathname.new(entry.path)
27
- self_path = Pathname.new(self.path)
28
- entry_path.exist? && self_path.exist? && entry_path.realpath == self_path.realpath
25
+ def ==(other)
26
+ other_path = Pathname.new(other.path)
27
+ self_path = Pathname.new(path)
28
+ other_path.exist? && self_path.exist? && other_path.realpath == self_path.realpath
29
29
  end
30
30
 
31
31
  def repo
@@ -36,4 +36,4 @@ module MultiRepo
36
36
  repo.basename
37
37
  end
38
38
  end
39
- end
39
+ end
@@ -20,7 +20,7 @@ module MultiRepo
20
20
  end
21
21
 
22
22
  def exists?
23
- File.exists?(file)
23
+ File.exist?(file)
24
24
  end
25
25
 
26
26
  def load_entries
@@ -43,4 +43,4 @@ module MultiRepo
43
43
  save_entries(load_entries.delete_if { |e| e == entry })
44
44
  end
45
45
  end
46
- end
46
+ end
@@ -26,4 +26,4 @@ module MultiRepo
26
26
  @branch = current_branch ? current_branch.name : nil
27
27
  end
28
28
  end
29
- end
29
+ end
@@ -22,7 +22,7 @@ module MultiRepo
22
22
  end
23
23
 
24
24
  def exists?
25
- File.exists?(file)
25
+ File.exist?(file)
26
26
  end
27
27
 
28
28
  def load_entries
@@ -53,4 +53,4 @@ module MultiRepo
53
53
  return valid
54
54
  end
55
55
  end
56
- end
56
+ end
@@ -38,4 +38,4 @@ module MultiRepo
38
38
  return update_internal(file, content)
39
39
  end
40
40
  end
41
- end
41
+ end
@@ -1,9 +1,9 @@
1
1
  module MultiRepo
2
2
  class TrackingFile
3
3
  def update_internal(file, new_content)
4
- old_content = File.exists?(file) ? File.read(file) : nil
4
+ old_content = File.exist?(file) ? File.read(file) : nil
5
5
  File.write(file, new_content)
6
6
  return new_content != old_content
7
7
  end
8
8
  end
9
- end
9
+ end
@@ -44,4 +44,4 @@ module MultiRepo
44
44
  files.map{ |f| File.basename(f.file) }.join(" ")
45
45
  end
46
46
  end
47
- end
47
+ end
@@ -5,7 +5,7 @@ module MultiRepo
5
5
  class Branch < Ref
6
6
  def exists?
7
7
  lines = GitRunner.run(@repo.path, "branch", Verbosity::OUTPUT_NEVER).split("\n")
8
- branch_names = lines.map { |line| line.tr("* ", "")}
8
+ branch_names = lines.map { |line| line.tr("* ", "") }
9
9
  branch_names.include?(@name)
10
10
  end
11
11
 
@@ -29,4 +29,4 @@ module MultiRepo
29
29
  GitRunner.last_command_succeeded
30
30
  end
31
31
  end
32
- end
32
+ end
@@ -8,4 +8,4 @@ module MultiRepo
8
8
  @path = line[3..-1]
9
9
  end
10
10
  end
11
- end
11
+ end
@@ -4,4 +4,4 @@ require_relative "git-runner"
4
4
  module MultiRepo
5
5
  class Commit < Ref
6
6
  end
7
- end
7
+ end
@@ -19,8 +19,6 @@ module MultiRepo
19
19
  runner_system(command)
20
20
  end
21
21
 
22
- private
23
-
24
22
  def self.build_command(path, git_command)
25
23
  if path == "."
26
24
  # It is always better to skip -C when running git commands in the
@@ -30,7 +28,7 @@ module MultiRepo
30
28
  return "#{git_executable} #{git_command}"
31
29
  end
32
30
 
33
- full_command = "#{git_executable} -C \"#{path}\" #{git_command}";
31
+ full_command = "#{git_executable} -C \"#{path}\" #{git_command}"
34
32
  if Config.instance.running_git_hook
35
33
  # True fix for the -C flag issue in pre-commit hook where the status command would
36
34
  # fail to provide correct results if a pathspec was provided when performing a commit.
@@ -55,4 +53,4 @@ module MultiRepo
55
53
  Config.instance.git_executable || "git"
56
54
  end
57
55
  end
58
- end
56
+ end
@@ -7,4 +7,4 @@ module MultiRepo
7
7
  GitRunner.last_command_succeeded
8
8
  end
9
9
  end
10
- end
10
+ end
@@ -22,7 +22,7 @@ module MultiRepo
22
22
  GitRunner.run(@repo.path, "rev-parse --short #{@name}", Verbosity::OUTPUT_NEVER).strip
23
23
  end
24
24
 
25
- def is_merge?
25
+ def merge_commit?
26
26
  lines = GitRunner.run(@repo.path, "cat-file -p #{@name}", Verbosity::OUTPUT_NEVER).split("\n")
27
27
  parents = lines.grep(/^parent /)
28
28
  return parents.count > 1
@@ -35,4 +35,4 @@ module MultiRepo
35
35
  return merge_base_output == rev_parse_output
36
36
  end
37
37
  end
38
- end
38
+ end
@@ -14,4 +14,4 @@ module MultiRepo
14
14
  return output == "" ? nil : output
15
15
  end
16
16
  end
17
- end
17
+ end
@@ -34,16 +34,16 @@ module MultiRepo
34
34
  end
35
35
 
36
36
  def local_branches
37
- branches_by_removing_prefix(/^refs\/heads\//)
37
+ branches_by_removing_prefix(%r{^refs/heads/})
38
38
  end
39
39
 
40
40
  def remote_branches
41
- branches_by_removing_prefix(/^refs\/remotes\//)
41
+ branches_by_removing_prefix(%r{^refs/remotes/})
42
42
  end
43
43
 
44
44
  def changes
45
45
  output = GitRunner.run(@path, "status --porcelain", Verbosity::OUTPUT_NEVER)
46
- lines = output.split("\n").each{ |f| f.strip }.delete_if{ |f| f == "" }
46
+ lines = output.split("\n").each(&:strip).delete_if{ |f| f == "" }
47
47
  lines.map { |l| Change.new(l) }
48
48
  end
49
49
 
@@ -55,7 +55,7 @@ module MultiRepo
55
55
  end
56
56
 
57
57
  def clone(url, branch = nil)
58
- if branch != nil
58
+ if !branch.nil?
59
59
  GitRunner.run_as_system(".", "clone #{url} -b #{branch} #{@path} --progress")
60
60
  else
61
61
  GitRunner.run_as_system(".", "clone #{url} #{@path} --progress")
@@ -116,8 +116,8 @@ module MultiRepo
116
116
  all_refs = all_refs.map { |l| l.sub(/^\'/, "").sub(/\'$/, "") }
117
117
 
118
118
  full_names = all_refs.select { |r| r =~ prefix_regex }
119
- names = full_names.map{ |f| f.sub(prefix_regex, "") }.delete_if{ |n| n =~ /HEAD$/}
119
+ names = full_names.map{ |f| f.sub(prefix_regex, "") }.delete_if{ |n| n =~ /HEAD$/ }
120
120
  names.map { |b| Branch.new(self, b) }
121
121
  end
122
122
  end
123
- end
123
+ end
@@ -20,4 +20,4 @@ module MultiRepo
20
20
  exit 1
21
21
  end
22
22
  end
23
- end
23
+ end
@@ -32,4 +32,4 @@ module MultiRepo
32
32
  exit 1
33
33
  end
34
34
  end
35
- end
35
+ end
@@ -3,4 +3,4 @@ module MultiRepo
3
3
  attr_accessor :config_entry
4
4
  attr_accessor :lock_entry
5
5
  end
6
- end
6
+ end
@@ -35,20 +35,20 @@ module MultiRepo
35
35
 
36
36
  def merge_description
37
37
  case @state
38
- when TheirState::NON_EXISTENT; "No revision named #{@their_revision}".red
38
+ when TheirState::NON_EXISTENT then "No revision named #{@their_revision}".red
39
39
  else; "Merge '#{@state == TheirState::EXACT_REF ? @short_commit_id : @their_revision}' into '#{@our_revision}'"
40
40
  end
41
41
  end
42
42
 
43
43
  def upstream_description
44
44
  case @state
45
- when TheirState::NON_EXISTENT; "--"
46
- when TheirState::EXACT_REF; "Exact ref".yellow
47
- when TheirState::LOCAL_NO_UPSTREAM; "Not remote-tracking".yellow
48
- when TheirState::UPSTREAM_NO_LOCAL; "Branch is upstream".green
49
- when TheirState::LOCAL_UP_TO_DATE; "Local up-to-date with upstream".green
50
- when TheirState::LOCAL_OUTDATED; "Local outdated compared to upstream".yellow
51
- when TheirState::LOCAL_UPSTREAM_DIVERGED; "Local and upstream have diverged!".red
45
+ when TheirState::NON_EXISTENT then "--"
46
+ when TheirState::EXACT_REF then "Exact ref".yellow
47
+ when TheirState::LOCAL_NO_UPSTREAM then "Not remote-tracking".yellow
48
+ when TheirState::UPSTREAM_NO_LOCAL then "Branch is upstream".green
49
+ when TheirState::LOCAL_UP_TO_DATE then "Local up-to-date with upstream".green
50
+ when TheirState::LOCAL_OUTDATED then "Local outdated compared to upstream".yellow
51
+ when TheirState::LOCAL_UPSTREAM_DIVERGED then "Local and upstream have diverged!".red
52
52
  end
53
53
  end
54
54
 
@@ -57,8 +57,8 @@ module MultiRepo
57
57
  def determine_merge_state(repo, their_ref)
58
58
  return TheirState::NON_EXISTENT unless their_ref.exists?
59
59
 
60
- remote_branch = repo.remote_branches.select{ |b| b.name == their_ref.name }.first
61
- local_branch = repo.local_branches.select{ |b| b.name == their_ref.name }.first
60
+ remote_branch = repo.remote_branches.find { |b| b.name == their_ref.name }
61
+ local_branch = repo.local_branches.find { |b| b.name == their_ref.name }
62
62
 
63
63
  # If no local branch nor remote branch exist for their_ref, this is an exact ref
64
64
  return TheirState::EXACT_REF unless remote_branch || local_branch
@@ -92,4 +92,4 @@ module MultiRepo
92
92
  return state
93
93
  end
94
94
  end
95
- end
95
+ end
@@ -17,7 +17,7 @@ module MultiRepo
17
17
  end
18
18
 
19
19
  def children
20
- return [] unless Utils.is_multirepo_enabled(@path)
20
+ return [] unless Utils.multirepo_enabled?(@path)
21
21
  config_entries = ConfigFile.new(@path).load_entries
22
22
  return config_entries.map { |e| Node.new(e.path, self, @depth + 1) }
23
23
  end
@@ -29,13 +29,13 @@ module MultiRepo
29
29
  def ordered_descendants
30
30
  descendants = find_descendants_recursive(self)
31
31
 
32
- unique_paths = descendants.map{ |d| d.path }.uniq
32
+ unique_paths = descendants.map(&:path).uniq
33
33
  unique_nodes = unique_paths.collect do |path|
34
34
  nodes_for_path = descendants.select { |d| d.path == path }
35
- next nodes_for_path.sort{ |n| n.depth }.first
35
+ next nodes_for_path.sort_by(&:depth).first
36
36
  end
37
37
 
38
- return unique_nodes.sort_by{ |d| d.depth }.reverse
38
+ return unique_nodes.sort_by(&:depth).reverse
39
39
  end
40
40
 
41
41
  def find_descendants_recursive(node)
@@ -58,15 +58,15 @@ module MultiRepo
58
58
  description = "itself" if visited.count == 1
59
59
  Console.log_warning("'#{n.path}' depends on #{description}")
60
60
  end
61
- raise MultiRepoException, "Dependency cycles are not supported by multirepo."
61
+ fail MultiRepoException, "Dependency cycles are not supported by multirepo."
62
62
  end
63
63
  parent = parent.parent # Will eventually be nil (root node), which will break out of the loop
64
64
  end
65
65
  end
66
66
 
67
- def ==(object)
68
- object.class == self.class &&
69
- object.path == @path
67
+ def ==(other)
68
+ other.class == self.class &&
69
+ other.path == @path
70
70
  end
71
71
  end
72
- end
72
+ end
@@ -8,19 +8,19 @@ module MultiRepo
8
8
  def self.perform_main_repo_checkout(main_repo, ref_name, message = nil)
9
9
  # Make sure the main repo is clean before attempting a checkout
10
10
  unless main_repo.clean?
11
- raise MultiRepoException, "Can't checkout #{ref_name} because the main repo contains uncommitted changes"
11
+ fail MultiRepoException, "Can't checkout #{ref_name} because the main repo contains uncommitted changes"
12
12
  end
13
13
 
14
14
  # Checkout the specified ref
15
15
  unless main_repo.checkout(ref_name)
16
- raise MultiRepoException, "Couldn't perform checkout of main repo #{ref_name}!"
16
+ fail MultiRepoException, "Couldn't perform checkout of main repo #{ref_name}!"
17
17
  end
18
18
 
19
19
  Console.log_substep(message || "Checked out main repo #{ref_name}")
20
20
 
21
21
  # After checkout, make sure we're working with a multirepo-enabled ref
22
- unless Utils.is_multirepo_tracked(".")
23
- raise MultiRepoException, "Revision #{ref_name} is not tracked by multirepo!"
22
+ unless Utils.multirepo_tracked?(".")
23
+ fail MultiRepoException, "Revision #{ref_name} is not tracked by multirepo!"
24
24
  end
25
25
  end
26
26
 
@@ -32,12 +32,10 @@ module MultiRepo
32
32
  dependency_ordered_nodes = Node.new(".").ordered_descendants
33
33
 
34
34
  return dependency_ordered_nodes.map do |node|
35
- pair = dependencies.find { |d| d.config_entry.path == node.path }
35
+ dependencies.find { |d| d.config_entry.path == node.path }
36
36
  end
37
37
  end
38
38
 
39
- private
40
-
41
39
  def self.build_dependencies(config_entries, lock_entries)
42
40
  lock_entries.map do |lock_entry|
43
41
  config_entry = config_entry_for_lock_entry(config_entries, lock_entry)
@@ -54,4 +52,4 @@ module MultiRepo
54
52
  config_entries.find { |config_entry| config_entry.id == lock_entry.id }
55
53
  end
56
54
  end
57
- end
55
+ end
@@ -6,18 +6,18 @@ module MultiRepo
6
6
 
7
7
  def self.name_for_mode(mode)
8
8
  case mode
9
- when AS_LOCK; "as-lock"
10
- when LATEST; "latest"
11
- when EXACT; "exact"
9
+ when AS_LOCK then "as-lock"
10
+ when LATEST then "latest"
11
+ when EXACT then "exact"
12
12
  end
13
13
  end
14
14
  end
15
15
 
16
16
  class RevisionSelector
17
17
  def self.mode_for_args(checkout_latest, checkout_exact)
18
- if checkout_latest then
18
+ if checkout_latest
19
19
  RevisionSelectionMode::LATEST
20
- elsif checkout_exact then
20
+ elsif checkout_exact
21
21
  RevisionSelectionMode::EXACT
22
22
  else
23
23
  RevisionSelectionMode::AS_LOCK
@@ -26,10 +26,10 @@ module MultiRepo
26
26
 
27
27
  def self.revision_for_mode(mode, ref_name, lock_entry)
28
28
  case mode
29
- when RevisionSelectionMode::AS_LOCK; lock_entry.head
30
- when RevisionSelectionMode::LATEST; lock_entry.branch
31
- when RevisionSelectionMode::EXACT; ref_name
29
+ when RevisionSelectionMode::AS_LOCK then lock_entry.head
30
+ when RevisionSelectionMode::LATEST then lock_entry.branch
31
+ when RevisionSelectionMode::EXACT then ref_name
32
32
  end
33
33
  end
34
34
  end
35
- end
35
+ end
@@ -3,4 +3,4 @@ require "claide/informative_error"
3
3
  module MultiRepo
4
4
  class MultiRepoException < StandardError
5
5
  end
6
- end
6
+ end
@@ -29,7 +29,7 @@ module MultiRepo
29
29
 
30
30
  def self.ask_yes_no(message)
31
31
  answered = false
32
- while !answered
32
+ until answered
33
33
  print_prefix
34
34
  print message
35
35
  print " (y/n) "
@@ -49,4 +49,4 @@ module MultiRepo
49
49
  print $stdout.isatty ? "> ".white : "[multirepo] "
50
50
  end
51
51
  end
52
- end
52
+ end
@@ -9,7 +9,7 @@ module MultiRepo
9
9
 
10
10
  lines = []
11
11
  last_command_succeeded = false
12
- Open3.popen2e(cmd) do |stdin, stdout_and_stderr, thread|
12
+ Open3.popen2e(cmd) do |_stdin, stdout_and_stderr, thread|
13
13
  stdout_and_stderr.each do |line|
14
14
  print line if Config.instance.verbose
15
15
  lines << line
@@ -24,4 +24,4 @@ module MultiRepo
24
24
  return output, last_command_succeeded
25
25
  end
26
26
  end
27
- end
27
+ end
@@ -11,4 +11,4 @@ module MultiRepo
11
11
  return output, last_command_succeeded
12
12
  end
13
13
  end
14
- end
14
+ end
@@ -8,12 +8,12 @@ module MultiRepo
8
8
  File.join(gem_path, "resources/#{resource_name}")
9
9
  end
10
10
 
11
- def self.is_multirepo_enabled(path)
12
- File.exists?(File.join(path, ".multirepo"))
11
+ def self.multirepo_enabled?(path)
12
+ File.exist?(File.join(path, ".multirepo"))
13
13
  end
14
14
 
15
- def self.is_multirepo_tracked(path)
16
- is_multirepo_enabled(path) && File.exists?(File.join(path, ".multirepo.lock"))
15
+ def self.multirepo_tracked?(path)
16
+ multirepo_enabled?(path) && File.exist?(File.join(path, ".multirepo.lock"))
17
17
  end
18
18
 
19
19
  def self.install_hook(name, path)
@@ -25,7 +25,7 @@ module MultiRepo
25
25
 
26
26
  def self.sibling_repos
27
27
  sibling_directories = Dir['../*/']
28
- sibling_repos = sibling_directories.map{ |d| Repo.new(d) }.select{ |r| r.exists? }
28
+ sibling_repos = sibling_directories.map{ |d| Repo.new(d) }.select(&:exists?)
29
29
  sibling_repos.delete_if{ |r| Pathname.new(r.path).realpath == Pathname.new(".").realpath }
30
30
  end
31
31
 
@@ -46,8 +46,8 @@ module MultiRepo
46
46
  Console.log_warning("Dependency '#{e.repo.path}' contains uncommitted changes") unless dependency_clean
47
47
  end
48
48
 
49
- raise MultiRepoException, "Some dependencies are not present on this machine." +
50
- " Run \"multi install\" to clone missing dependencies." if missing
49
+ fail MultiRepoException, "Some dependencies are not present on this machine." \
50
+ " Run \"multi install\" to clone missing dependencies." if missing
51
51
 
52
52
  return clean
53
53
  end
@@ -69,27 +69,27 @@ module MultiRepo
69
69
 
70
70
  def self.reveal_in_default_file_browser(unix_path)
71
71
  if OS.osx?
72
- system %{open "#{unix_path}"}
72
+ system %(open "#{unix_path}")
73
73
  elsif OS.windows?
74
- system %{explorer "#{Utils.convert_to_windows_path(unix_path)}"}
74
+ system %(explorer "#{Utils.convert_to_windows_path(unix_path)}")
75
75
  end
76
76
  end
77
77
 
78
78
  def self.open_in_default_app(unix_path)
79
79
  if OS.osx?
80
- system %{open "#{unix_path}"}
80
+ system %(open "#{unix_path}")
81
81
  elsif OS.windows?
82
- system %{cmd /c "start C:\\#{Utils.convert_to_windows_path(unix_path)}"}
82
+ system %(cmd /c "start C:\\#{Utils.convert_to_windows_path(unix_path)}")
83
83
  end
84
84
  end
85
85
 
86
86
  def self.append_if_missing(path, pattern, string_to_append)
87
- unless File.exists?(path)
88
- File.open(path, 'w') { |f| f.puts(string_to_append) }
89
- else
87
+ if File.exist?(path)
90
88
  string_located = File.readlines(path).grep(pattern).any?
91
89
  File.open(path, 'a') { |f| f.puts(string_to_append) } unless string_located
90
+ else
91
+ File.open(path, 'w') { |f| f.puts(string_to_append) }
92
92
  end
93
93
  end
94
94
  end
95
- end
95
+ end
@@ -3,4 +3,4 @@ module MultiRepo
3
3
  OUTPUT_NEVER = 0
4
4
  OUTPUT_ON_ERROR = 1
5
5
  end
6
- end
6
+ end
@@ -3,4 +3,4 @@
3
3
  require "rubygems"
4
4
  require "git-multirepo"
5
5
 
6
- MultiRepo::PostCommitHook.run
6
+ MultiRepo::PostCommitHook.run
data/resources/pre-commit CHANGED
@@ -3,4 +3,4 @@
3
3
  require "rubygems"
4
4
  require "git-multirepo"
5
5
 
6
- MultiRepo::PreCommitHook.run
6
+ MultiRepo::PreCommitHook.run
@@ -16,4 +16,4 @@ RSpec.describe("Init") do
16
16
  it "fails when there are uncommitted changes in dependencies" do
17
17
  pending
18
18
  end
19
- end
19
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-multirepo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta47
4
+ version: 1.0.0.beta48
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michaël Fortin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-03 00:00:00.000000000 Z
11
+ date: 2015-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -143,6 +143,7 @@ files:
143
143
  - .multirepo.lock
144
144
  - .multirepo.meta
145
145
  - .rspec
146
+ - .rubocop.yml
146
147
  - Gemfile
147
148
  - Gemfile.lock
148
149
  - LICENSE