From cc4b8981f9c859f42a6948cf9bae3cc10ff18891 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohnic=CC=81?= Date: Sat, 26 Nov 2011 18:13:30 +0100 Subject: [PATCH] fall back to "/tmp" if $TMPDIR isn't set --- lib/hub/commands.rb | 2 +- test/hub_test.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/hub/commands.rb b/lib/hub/commands.rb index 45cead98..bab90083 100644 --- a/lib/hub/commands.rb +++ b/lib/hub/commands.rb @@ -366,7 +366,7 @@ module Hub url = url.sub(%r{(/pull/\d+)/\w*$}, '\1') unless gist ext = gist ? '.txt' : '.patch' url += ext unless File.extname(url) == ext - patch_file = File.join(ENV['TMPDIR'], "#{gist ? 'gist-' : ''}#{File.basename(url)}") + patch_file = File.join(ENV['TMPDIR'] || '/tmp', "#{gist ? 'gist-' : ''}#{File.basename(url)}") args.before 'curl', ['-#LA', "hub #{Hub::Version}", url, '-o', patch_file] args[idx] = patch_file end diff --git a/test/hub_test.rb b/test/hub_test.rb index 718a15a5..d87a0c44 100644 --- a/test/hub_test.rb +++ b/test/hub_test.rb @@ -404,6 +404,13 @@ class HubTest < Test::Unit::TestCase end end + def test_am_no_tmpdir + with_tmpdir(nil) do + cmd = Hub("am https://github.com/defunkt/hub/pull/55").command + assert_includes '/tmp/55.patch', cmd + end + end + def test_am_commit_url with_tmpdir('/tmp/') do url = 'https://github.com/davidbalbert/hub/commit/fdb9921' -- GitLab