git-multirepo 1.0.0.beta17 → 1.0.0.beta18

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2d6d791443ed5a120b81f84637cc1122c9f8611e
4
- data.tar.gz: d10a799594143bb6fc24681be6fafb07570b9c11
3
+ metadata.gz: d88cc72e2ecea7331cc379e0d48f771302960e0c
4
+ data.tar.gz: 3778236c3c5e1cfe17ba4c16b5e26d3fd54186ab
5
5
  SHA512:
6
- metadata.gz: c5bd81592ddb05d57730b49835106d917e07da5eec4465e5b8a8f58b1213a6f4cf6e613f8b0f2110dc879a19bb4bf81203ba5e4955f65b56924214fab106cee1
7
- data.tar.gz: 5d9feaa0464c5dbdb462a100e2bc8e5f89bc2288df2e7e11f81e422c0eb52f152c1174a04394ee6dd4c45793f77fe0a2dce0d4bcbb3cedc97915c92387f91d16
6
+ metadata.gz: 7bdbdeff71220ce72b005dc66ac91cd45e0afddf227c0732b84e102d587192a29db3522b97eff8a988b53761b7b301664aeacfd3a5e0af9ec217fb183b4dde2f
7
+ data.tar.gz: e9f0f748cbd0d2385fee936886eb759f09f5e17898af4510920e51930b7dac92fdb1975dbc148207a73eadd4c401634cd7870f036cf695b7a98131323a99ca40
data/README.md CHANGED
@@ -48,7 +48,7 @@ In essence:
48
48
  1. You tell git-multirepo what your dependencies are.
49
49
  2. Each time you commit the main repo, git-multirepo tracks what revision of each dependency is required by the project (don't worry, it ensures that you don't forget to commit changes to dependencies beforehand; more on that later).
50
50
  3. If you ever want to go back to a previous version of your project, git-multirepo handles checking out the main repo and appropriate revisions of all of its dependencies in a single, seamless operation.
51
- 4. Setting up the project on a new machine is only a single `git clone` and `multi install` away.
51
+ 4. Setting up the project on a new machine is only a single `multi clone` away.
52
52
 
53
53
  ## Example
54
54
 
@@ -74,9 +74,9 @@ If you want to add another dependency later on, you can run `multi add ../NewDep
74
74
 
75
75
  If you want to checkout a previous revision (say `e690d`), you use the checkout command: `multi checkout e690d`. This will checkout the main repo's `e690d` revision and all of its dependencies with the proper revisions in detached HEAD state.
76
76
 
77
- If you want to setup your project on another machine, simply clone the main repo in a container directory (see above) and run `multi install`. This will clone each dependency and checkout the appropriate branches.
77
+ If you want to setup your project on another machine, simply run `multi clone` with the appropriate parameters. This will clone the project and each of its dependencies, then checkout the appropriate work branches.
78
78
 
79
- If you want to stop using git-multirepo, run `multi uninit`. This will remove all traces of git-multirepo from your repository and working copy.
79
+ If you want to stop using git-multirepo, run `multi uninit`. This will remove all traces of git-multirepo from your repository and working copy, including local git hooks.
80
80
 
81
81
  ## Advantages
82
82
 
@@ -96,15 +96,15 @@ If you want to stop using git-multirepo, run `multi uninit`. This will remove al
96
96
  | Merging Changes to Dependencies | easy | hard | passable |
97
97
  | Contributing Upstream | easy | easy | passable |
98
98
  | Continuous Integration | medium | medium | easy |
99
- | Complex Branch-Based Workflows | hard* | hard | easy |
99
+ | Complex Branch-Based Workflows | medium* | hard | easy |
100
100
 
101
- (*) This should get better in future versions of git-multirepo.
101
+ (*) Ongoing work should make this easier in future versions of git-multirepo.
102
102
 
103
103
  ## Limitations
104
104
 
105
105
  - git-multirepo should be considered beta at the moment. All of the core features work as described, though. Suggestions and contributions are welcome.
106
106
  - The project and its dependencies must live beside each other on disk (for now).
107
- - There are currently no features to facilitate branch-heavy workflows.
107
+ - Some more commands need to be implemented to facilitate branch-heavy workflows.
108
108
  - You must (ideally) install the tool on your CI server: `gem install git-multirepo`
109
109
 
110
110
  ## Summary of Commands
@@ -120,7 +120,7 @@ Here is a quick rundown of commands available to you in git-multirepo:
120
120
  | clone | Clones the specified repository in a subfolder, then installs it. |
121
121
  | edit | Opens the .multirepo file in the default text editor. |
122
122
  | fetch | Performs a git fetch on all dependencies. |
123
- | install | Clones and checks out dependencies as defined in the .multirepo file, and installs git-multirepo's local pre-commit hook. |
123
+ | install | Clones and checks out dependencies as defined in the version-controlled multirepo metadata files and installs git-multirepo's local git hooks. |
124
124
  | open | Opens all dependencies in the current OS's file explorer. |
125
125
  | remove | Removes the specified dependency from multirepo. |
126
126
  | update | Force-updates the multirepo lock file. |
@@ -134,7 +134,7 @@ git-multirepo stores all of its metadata in two files:
134
134
 
135
135
  | File | Format | Contents |
136
136
  |------|--------|----------|
137
- | .multirepo | YAML | A collection of your project's dependencies. For each dependency, stores its **local path** relative to the main repo, the **remote URL** and the **work branch** your project depends upon.
137
+ | .multirepo | YAML | A collection of your project's dependencies. For each dependency, stores its **local path** relative to the main repo and the **remote URL** your project depends upon.
138
138
  | .multirepo.lock | YAML | For each dependency, stores the **commit hash** and **branch** on which the dependency was when the main repo was committed. The dependency's **name** is also included but only serves as a reference to make inspecting the lock file easier. |
139
139
 
140
140
  The information contained in .multirepo and .multirepo.lock allow one-step cloning of a project and all its dependencies, and checking out any prior revision of the main project with appropriate revisions of all of its dependencies, respectively.
data/lib/info.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module MultiRepo
2
2
  NAME = "git-multirepo"
3
- VERSION = "1.0.0.beta17"
3
+ VERSION = "1.0.0.beta18"
4
4
  DESCRIPTION = "Track multiple Git repositories side-by-side."
5
5
  end
@@ -5,9 +5,15 @@ module MultiRepo
5
5
  self.command = "checkout"
6
6
  self.summary = "Checks out the specified commit or branch of the main repo and checks out matching versions of all dependencies."
7
7
 
8
+ class CheckoutMode
9
+ AS_LOCK = 0
10
+ LATEST = 1
11
+ EXACT = 2
12
+ end
13
+
8
14
  def self.options
9
15
  [
10
- ['[ref]', 'The main repo tag, branch or commit hash to checkout.'],
16
+ ['[ref]', 'The main repo tag, branch or commit id to checkout.'],
11
17
  ['--latest', 'Checkout the HEAD of each dependency branch (as recorded in the lock file) instead of the exact required commits.'],
12
18
  ['--exact', 'Checkout the exact specified ref for each repo, regardless of what\'s stored in the lock file.']
13
19
  ].concat(super)
@@ -30,20 +36,37 @@ module MultiRepo
30
36
  validate_in_work_tree
31
37
  ensure_multirepo_initialized
32
38
 
39
+ Console.log_step("Checking out #{@ref} and its dependencies...")
40
+
41
+ # Find out the checkout mode based on command-line options
42
+ mode = if @checkout_latest then
43
+ CheckoutMode::LATEST
44
+ elsif @checkout_exact then
45
+ CheckoutMode::EXACT
46
+ else
47
+ CheckoutMode::AS_LOCK
48
+ end
49
+
50
+ checkout_core(@ref, mode)
51
+
52
+ Console.log_step("Done!")
53
+ rescue MultiRepoException => e
54
+ Console.log_error(e.message)
55
+ end
56
+
57
+ def checkout_core(ref, mode)
33
58
  main_repo = Repo.new(".")
34
59
  initial_revision = main_repo.current_branch || main_repo.head_hash
35
-
36
- Console.log_step("Checking out #{@ref} and its dependencies...")
37
60
 
38
61
  unless main_repo.is_clean?
39
- raise MultiRepoException, "Can't checkout #{@ref} because the main repo contains uncommitted changes"
62
+ raise MultiRepoException, "Can't checkout #{ref} because the main repo contains uncommitted changes"
40
63
  end
41
64
 
42
- unless main_repo.checkout(@ref)
43
- raise MultiRepoException, "Couldn't perform checkout of main repo #{@ref}!"
65
+ unless main_repo.checkout(ref)
66
+ raise MultiRepoException, "Couldn't perform checkout of main repo #{ref}!"
44
67
  end
45
68
 
46
- Console.log_substep("Checked out main repo #{@ref}")
69
+ Console.log_substep("Checked out main repo #{ref}")
47
70
 
48
71
  unless LockFile.exists?
49
72
  main_repo.checkout(initial_revision)
@@ -59,15 +82,19 @@ module MultiRepo
59
82
  LockFile.load.each do |lock_entry|
60
83
  config_entry = config_entries.select{ |config_entry| config_entry.id == lock_entry.id }.first
61
84
 
62
- # First, make sure the repo exists on disk (in case the checked-out revision had an additional dependency)
85
+ # First, make sure the repo exists on disk, and clone it if it doesn't
86
+ # (in case the checked-out revision had an additional dependency)
63
87
  unless config_entry.repo.exists?
64
88
  Console.log_substep("Cloning missing dependency #{config_entry.path} from #{config_entry.url}")
65
89
  config_entry.repo.clone(config_entry.url)
66
90
  end
67
91
 
68
- # Find out the actual revision to checkout based on command flags
69
- revision = @checkout_latest ? lock_entry.branch : lock_entry.head
70
- revision = @checkout_exact ? @ref : revision
92
+ # Find out the proper revision to checkout based on the checkout mode
93
+ revision = case mode
94
+ when CheckoutMode::AS_LOCK; lock_entry.head
95
+ when CheckoutMode::LATEST; lock_entry.branch
96
+ when CheckoutMode::EXACT; ref
97
+ end
71
98
 
72
99
  # Checkout!
73
100
  if config_entry.repo.checkout(revision)
@@ -76,10 +103,6 @@ module MultiRepo
76
103
  raise MultiRepoException, "Couldn't check out the appropriate version of dependency #{lock_entry.name}"
77
104
  end
78
105
  end
79
-
80
- Console.log_step("Done!")
81
- rescue MultiRepoException => e
82
- Console.log_error(e.message)
83
106
  end
84
107
  end
85
108
  end
@@ -11,13 +11,15 @@ module MultiRepo
11
11
  def self.options
12
12
  [
13
13
  ['[url]', 'The repository to clone.'],
14
- ['[name]', 'The name of the containing folder that will be created.']
14
+ ['[name]', 'The name of the containing folder that will be created.'],
15
+ ['[ref]', 'The branch, tag or commit id to checkout. Checkout will use "master" if unspecified.']
15
16
  ].concat(super)
16
17
  end
17
18
 
18
19
  def initialize(argv)
19
20
  @url = argv.shift_argument
20
21
  @name = argv.shift_argument
22
+ @ref = argv.shift_argument
21
23
  super
22
24
  end
23
25
 
@@ -42,7 +44,8 @@ module MultiRepo
42
44
  original_path = Dir.pwd
43
45
  Dir.chdir(main_repo_path)
44
46
 
45
- InstallCommand.new(CLAide::ARGV.new([])).install_internal
47
+ install_command = InstallCommand.new(CLAide::ARGV.new([]))
48
+ install_command.install_core(@ref)
46
49
 
47
50
  Dir.chdir(original_path)
48
51
 
@@ -1,43 +1,57 @@
1
1
  require "multirepo/utility/console"
2
2
  require "multirepo/utility/utils"
3
3
  require "multirepo/git/repo"
4
+ require "multirepo/commands/checkout-command"
4
5
 
5
6
  module MultiRepo
6
7
  class InstallCommand < Command
7
8
  self.command = "install"
8
- self.summary = "Clones and checks out dependencies as defined in the .multirepo file, and installs git-multirepo's local hooks."
9
+ self.summary = "Clones and checks out dependencies as defined in the version-controlled multirepo metadata files and installs git-multirepo's local git hooks."
9
10
 
11
+ def self.options
12
+ [['[ref]', 'The branch, tag or commit id to checkout. Checkout will use "master" if unspecified.']].concat(super)
13
+ end
14
+
15
+ def initialize(argv)
16
+ @ref = argv.shift_argument
17
+ super
18
+ end
19
+
10
20
  def run
11
21
  validate_in_work_tree
12
22
  ensure_multirepo_initialized
13
23
 
14
24
  Console.log_step("Cloning dependencies and installing hook...")
15
25
 
16
- install_internal
26
+ install_core(@ref)
17
27
 
18
28
  Console.log_step("Done!")
19
29
  rescue MultiRepoException => e
20
30
  Console.log_error(e.message)
21
31
  end
22
32
 
23
- def install_internal
33
+ def install_core(ref)
24
34
  config_entries = ConfigFile.load
25
35
 
26
36
  Console.log_substep("Installing #{config_entries.count} dependencies...");
27
37
 
28
- config_entries.each { |e| install(e) }
38
+ # Clone or fetch configured repos
39
+ config_entries.each { |e| clone_or_fetch(e) }
40
+
41
+ # Checkout the repos as specified in the lock file
42
+ checkout_command = CheckoutCommand.new(CLAide::ARGV.new([]))
43
+ checkout_command.checkout_core(ref || "master", CheckoutCommand::CheckoutMode::LATEST)
29
44
 
30
45
  install_hooks
31
46
  end
32
47
 
33
- def install(entry)
48
+ def clone_or_fetch(entry)
34
49
  if entry.repo.exists?
35
50
  check_repo_validity(entry)
36
51
  fetch_repo(entry)
37
52
  else
38
53
  clone_repo(entry)
39
54
  end
40
- checkout_branch(entry)
41
55
  end
42
56
 
43
57
  # Repo operations
@@ -8,14 +8,12 @@ module MultiRepo
8
8
  attr_accessor :id
9
9
  attr_accessor :path
10
10
  attr_accessor :url
11
- attr_accessor :branch
12
11
  attr_accessor :repo
13
12
 
14
13
  def encode_with(coder)
15
14
  coder["id"] = @id
16
15
  coder["path"] = @path
17
16
  coder["url"] = @url
18
- coder["branch"] = @branch
19
17
  end
20
18
 
21
19
  def ==(entry)
@@ -28,7 +26,6 @@ module MultiRepo
28
26
  @id = SecureRandom.uuid
29
27
  @path = repo.path
30
28
  @url = repo.exists? ? repo.remote('origin').url : nil
31
- @branch = repo.exists? ? repo.current_branch : nil
32
29
  end
33
30
 
34
31
  def repo
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.beta17
4
+ version: 1.0.0.beta18
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-03-28 00:00:00.000000000 Z
11
+ date: 2015-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler