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 +4 -4
- data/README.md +8 -8
- data/lib/info.rb +1 -1
- data/lib/multirepo/commands/checkout-command.rb +38 -15
- data/lib/multirepo/commands/clone-command.rb +5 -2
- data/lib/multirepo/commands/install-command.rb +20 -6
- data/lib/multirepo/files/config-entry.rb +0 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d88cc72e2ecea7331cc379e0d48f771302960e0c
|
4
|
+
data.tar.gz: 3778236c3c5e1cfe17ba4c16b5e26d3fd54186ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 `
|
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
|
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 |
|
99
|
+
| Complex Branch-Based Workflows | medium* | hard | easy |
|
100
100
|
|
101
|
-
(*)
|
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
|
-
-
|
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
|
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
|
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
@@ -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
|
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 #{
|
62
|
+
raise MultiRepoException, "Can't checkout #{ref} because the main repo contains uncommitted changes"
|
40
63
|
end
|
41
64
|
|
42
|
-
unless main_repo.checkout(
|
43
|
-
raise MultiRepoException, "Couldn't perform checkout of main repo #{
|
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 #{
|
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
|
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
|
69
|
-
revision =
|
70
|
-
|
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([]))
|
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
|
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
|
-
|
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
|
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
|
-
|
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
|
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.
|
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-
|
11
|
+
date: 2015-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|