Skip to content

Commit

Permalink
Fixed 'init release --git' + 1.8 bugs
Browse files Browse the repository at this point in the history
* --git was only working with base dir given;
* 1.8 CLI spec suite was failing (1 test);
* progress bar with new blobs didn't work with 1.8 (fixed by flushing
  stdout).

Change-Id: I5a6449897e0af360160d7a1bfba2e04f4fc95598
  • Loading branch information
olegshaldybin committed Apr 24, 2012
1 parent 6926aa2 commit 5ff0682
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
1 change: 1 addition & 0 deletions cli/lib/cli/blob_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ def download_blob(path)
def progress(path, label)
say("\r", " " * 80)
say("\r#{path.truncate(40).yellow} #{label}", "")
Bosh::Cli::Config.output.flush # Ruby 1.8 compatibility
end

# @param [String] src Path to a file containing the blob
Expand Down
19 changes: 11 additions & 8 deletions cli/lib/cli/commands/release.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,28 @@ class Release < Base
include Bosh::Cli::VersionCalc

def init(base=nil, *options)
flags = options.inject({}) { |h, option| h[option] = true; h }
git = flags.delete("--git")
if base[0..0] == "-"
# TODO: need to add some option parsing helpers to avoid that
options.unshift(base)
base = nil
end
git = options.include?("--git")

if base
FileUtils.mkdir_p(base) unless Dir.exist?(base)
Dir.chdir(base)
end

err("Release already initialized") if in_release_dir?

git_init if git

%w[jobs packages src blobs].each do |dir|
%w[config jobs packages src blobs].each do |dir|
FileUtils.mkdir(dir)
end

# initialize an empty blob_index file
blobs = {}
File.open("blob_index.yml", "w") do |f|
YAML.dump(blobs, f)
# Initialize an empty blobs index
File.open(File.join("config", "blobs.yml"), "w") do |f|
YAML.dump({}, f)
end

say("Release directory initialized".green)
Expand All @@ -44,6 +46,7 @@ def git_init
config/private.yml
releases/*.tgz
dev_releases
.blobs
blobs
.dev_builds
.idea
Expand Down
3 changes: 2 additions & 1 deletion cli/spec/unit/blob_manager_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ def make_manager(release)
end

@manager = make_manager(@release)
@blobstore.should_receive(:get).with("deadbeef", tmp_file).
@blobstore.should_receive(:get).with("deadbeef",
an_instance_of(Tempfile)).
and_return { tmp_file.write("blob contents"); tmp_file.close }

path = @manager.download_blob("foo")
Expand Down

0 comments on commit 5ff0682

Please sign in to comment.