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

Commit

Permalink
Merge pull request #39 from devxoul/raise-exception-when-failed-install
Browse files Browse the repository at this point in the history
Raise an exception when failed to install.
  • Loading branch information
devxoul committed Oct 18, 2015
2 parents cab2f1e + c5348aa commit 40dd51c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
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

0 comments on commit 40dd51c

Please sign in to comment.