Permalink
Browse files

Ensure dir switching is cleaned up properly in case of exception

  • Loading branch information...
1 parent 4dd1477 commit ed88494c4e694ed121265222f98a89c59c630c73 @lsegal committed Jun 11, 2012
Showing with 4 additions and 3 deletions.
  1. +4 −3 lib/yard/cli/diff.rb
View
@@ -100,6 +100,7 @@ def load_git_commit(commit)
Dir.chdir(tmpdir)
log.info("git says: " + `git reset --hard #{commit}`.chomp)
generate_yardoc(tmpdir)
+ ensure
Dir.chdir(@old_path)
cleanup(commit_path)
end
@@ -166,9 +167,9 @@ def expand_and_parse(gemfile, io)
def generate_yardoc(dir)
olddir = Dir.pwd
- Dir.chdir(dir)
- log.enter_level(Logger::ERROR) { Yardoc.run('-n', '--no-save') }
- Dir.chdir(olddir)
+ Dir.chdir(dir) do
+ log.enter_level(Logger::ERROR) { Yardoc.run('-n', '--no-save') }
+ end
end
def expand_gem(gemfile, io)

0 comments on commit ed88494

Please sign in to comment.