Skip to content
Snippets Groups Projects
Unverified Commit 59c2a01c authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Make sure grit restores old timeout value even if exception occured

parent 4a1ccd04
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -90,9 +90,13 @@ module Grit
 
def self.with_timeout(timeout = 10)
old_timeout = Grit::Git.git_timeout
Grit::Git.git_timeout = timeout
yield
Grit::Git.git_timeout = old_timeout
begin
Grit::Git.git_timeout = timeout
yield
ensure
Grit::Git.git_timeout = old_timeout
end
end
 
attr_accessor :git_dir, :bytes_read, :work_tree
Loading
Loading
Loading
Loading
@@ -43,6 +43,18 @@ class TestGit < Test::Unit::TestCase
@git.something
end
 
def test_with_timeout_restored
begin
Grit::Git.with_timeout(4) do
raise 'wow'
end
rescue
nil
end
assert_equal Grit::Git.git_timeout, 5
end
def test_can_skip_timeout
Timeout.expects(:timeout).never
@git.something(:timeout => false)
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment