Skip to content
This repository has been archived by the owner on Jul 2, 2018. It is now read-only.

Raise an exception when failed to install. #39

Merged
merged 2 commits into from
Oct 18, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions lib/cocoaseeds/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -345,16 +345,18 @@ def install_seed(seed, dirname)

not_found = output.include?("not found")
if not_found and output.include?("repository")
say "[!] #{seed.name}: Couldn't find the repository.".red
raise Seeds::Exception.new\
"#{seed.name}: Couldn't find the repository."
elsif not_found and output.include?("upstream")
say "[!] #{seed.name}: Couldn't find the tag `#{seed.version}`.".red
raise Seeds::Exception.new\
"#{seed.name}: Couldn't find the tag `#{seed.version}`."
end

if seed.commit and not seed.version # checkout to commit
output = `cd #{dirname} 2>&1 && git checkout #{seed.commit} 2>&1`
if output.include?("did not match any")
say "[!] #{seed.name}: Couldn't find the commit "\
"`#{seed.commit}`.".red
raise Seeds::Exception.new\
"#{seed.name}: Couldn't find the commit `#{seed.commit}`."
end
end

Expand Down Expand Up @@ -383,10 +385,9 @@ def install_seed(seed, dirname)
output = `cd #{dirname} 2>&1 &&\
git fetch origin #{seed.version} --tags 2>&1 &&\
git checkout #{seed.version} 2>&1`
puts output
if output.include?("Couldn't find")
say "[!] #{seed.name}: Couldn't find the tag or branch named "\
"`#{seed.commit}`.".red
raise Seeds::Exception.new\
"#{seed.name}: Couldn't find the tag or branch `#{seed.version}`."
end

elsif seed.commit
Expand All @@ -397,8 +398,8 @@ def install_seed(seed, dirname)
git pull 2>&1 &&
git checkout #{seed.commit} 2>&1`
if output.include?("did not match any")
say "[!] #{seed.name}: Couldn't find the commit "\
"`#{seed.commit}`.".red
raise Seeds::Exception.new\
"#{seed.name}: Couldn't find the commit `#{seed.commit}`.".red
end
end

Expand Down
16 changes: 16 additions & 0 deletions test/test_install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,22 @@ def test_raise_github_both_tag_and_commit
assert_raises Seeds::Exception do @seed.install end
end


def test_raise_invalid_tag
seedfile %{
github "JLToast", "Hello, World!"
}
assert_raises Seeds::Exception do @seed.install end
end


def test_raise_invalid_commit
seedfile %{
github "JLToast", :commit => "Hello, World!"
}
assert_raises Seeds::Exception do @seed.install end
end

end


Expand Down