manifestly 2.1.0.pre.pre → 2.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dbe2b21d657ba066cc4dada41055eaaafefb03e5
4
- data.tar.gz: 2e59ff433c6d00b1f5b1c33560a6dc3e85891cd8
3
+ metadata.gz: f0c315b69f70efd0a0a9fbb96b837ec5b8003651
4
+ data.tar.gz: 252ae02ec9b3b53fe3f9022f5dac47be059d776f
5
5
  SHA512:
6
- metadata.gz: 1bc430ab5687f56cc6d316a4d8527aa815fa24279aea3fbb394d61c902989059618f470afb70e25a7f4ab7003beb6a21763ac56832673a24247095177414e184
7
- data.tar.gz: 25495301744d85db2524b62f390a5cb6d4222f63e1e1bb27854c10143447e363ecdc5dc155d75cc41ad22d78f40b95f29bc6c60807601befe851098f281760d2
6
+ metadata.gz: ddb360f349ff360da7593cecf02e6e0bfc8d94f181844cf4068866e5794f07c290fc5914835158d6e4db67a77957cc8be81c9dbffd43a7d79670ef1ac7c4fc71
7
+ data.tar.gz: b6a5647e87acad501c243acda516ff23a5f552f8c4439fc71bd0eefb64c3d798c84658042bbfc4689945f395ff4dc2d79d82fab4ca77523317b75a8b26bf99e2
data/README.md CHANGED
@@ -11,13 +11,9 @@ Manifestly is run as a standalone executable. Install with:
11
11
 
12
12
  $ gem install manifestly
13
13
 
14
- And then execute:
14
+ To update to the latest version:
15
15
 
16
- $ bundle
17
-
18
- Or install it yourself as:
19
-
20
- $ gem install manifestly
16
+ $ gem update manifestly
21
17
 
22
18
  ## Usage
23
19
 
@@ -200,19 +200,32 @@ module Manifestly
200
200
  desc "apply", "Sets the manifest's repository's current states to the commits listed in the manifest"
201
201
  search_paths_option
202
202
  file_option("apply")
203
+ method_option :update,
204
+ desc: "Updates (fetches) repository content if a manifest commit is not found",
205
+ banner: '',
206
+ aliases: "-u",
207
+ type: :boolean,
208
+ default: false,
209
+ required: false
203
210
  long_desc <<-DESC
204
211
  Check to make sure the repositories you are deploying from have their state committed.
205
212
  DESC
206
213
  def apply
207
214
  begin
208
215
  manifest = load_manifest(file: options[:file]) || return
216
+ manifest.items.each{ |item| item.checkout_commit!(options[:update]) }
209
217
  rescue Manifestly::ManifestItem::MultipleSameNameRepositories => e
210
218
  say "Multiple repositories have the same name (#{e.message}) so we " +
211
219
  "can't apply the manifest. Try limiting the search_paths or " +
212
220
  "separate the duplicates."
213
221
  return
222
+ rescue Manifestly::Repository::CommitNotPresent => e
223
+ say "Could not find commit #{e.sha} in repository #{e.repository.github_name_or_path}. " +
224
+ "Try running again with the `--update` option."
225
+ return
214
226
  end
215
- manifest.items.each(&:checkout_commit!)
227
+
228
+
216
229
  end
217
230
 
218
231
  desc "upload", "Upload a local manifest file to a manifest repository"
@@ -30,9 +30,8 @@ module Manifestly
30
30
  end
31
31
 
32
32
  def self.read_file(filename, repositories)
33
- File.open(filename, 'r') do |file|
34
- read_lines(file, repositories)
35
- end
33
+ lines = File.read(filename)
34
+ read_lines(lines, repositories)
36
35
  end
37
36
 
38
37
  def self.read_lines(lines, repositories)
@@ -26,8 +26,8 @@ module Manifestly
26
26
  @repository.fetch
27
27
  end
28
28
 
29
- def checkout_commit!
30
- @repository.checkout_commit(@commit.sha)
29
+ def checkout_commit!(fetch_if_unfound=false)
30
+ @repository.checkout_commit(@commit.sha, fetch_if_unfound)
31
31
  end
32
32
 
33
33
  def to_file_string
@@ -4,7 +4,15 @@ require 'ostruct'
4
4
  module Manifestly
5
5
  class Repository
6
6
 
7
- class CommitNotPresent < StandardError; end
7
+ class CommitNotPresent < StandardError
8
+ attr_reader :sha, :repository
9
+ def initialize(sha, repository)
10
+ @sha = sha
11
+ @repository = repository
12
+ super("SHA '#{sha}' not found in repository '#{repository.github_name_or_path}'")
13
+ end
14
+ end
15
+
8
16
  class ManifestUnchanged < StandardError; end
9
17
  class CommitContentError < StandardError; end
10
18
  class NoCommitsError < StandardError; end
@@ -101,7 +109,7 @@ module Manifestly
101
109
  begin
102
110
  git.gcommit(sha).tap(&:sha)
103
111
  rescue Git::GitExecuteError => e
104
- raise CommitNotPresent, "SHA not found: #{sha}"
112
+ raise CommitNotPresent.new(sha, self)
105
113
  end
106
114
  end
107
115
 
@@ -131,8 +139,25 @@ module Manifestly
131
139
  end
132
140
  end
133
141
 
134
- def checkout_commit(sha)
135
- git.checkout(sha)
142
+ def checkout_commit(sha, fetch_if_unfound=false)
143
+ begin
144
+ git.checkout(sha)
145
+ rescue Git::GitExecuteError => e
146
+ if is_commit_not_found_exception?(e)
147
+ if fetch_if_unfound
148
+ git.fetch
149
+ checkout_commit(sha, false)
150
+ else
151
+ raise CommitNotPresent.new(sha, self)
152
+ end
153
+ else
154
+ raise
155
+ end
156
+ end
157
+ end
158
+
159
+ def is_commit_not_found_exception?(e)
160
+ e.message.include?("fatal: reference is not a tree")
136
161
  end
137
162
 
138
163
  def current_branch_name
@@ -1,3 +1,3 @@
1
1
  module Manifestly
2
- VERSION = "2.1.0-pre"
2
+ VERSION = "2.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: manifestly
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0.pre.pre
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - JP Slavinsky
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-03 00:00:00.000000000 Z
11
+ date: 2016-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -183,9 +183,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
183
183
  version: '0'
184
184
  required_rubygems_version: !ruby/object:Gem::Requirement
185
185
  requirements:
186
- - - ">"
186
+ - - ">="
187
187
  - !ruby/object:Gem::Version
188
- version: 1.3.1
188
+ version: '0'
189
189
  requirements: []
190
190
  rubyforge_project:
191
191
  rubygems_version: 2.4.8