diff --git a/lib/hub/commands.rb b/lib/hub/commands.rb index 45cead98b33632f85ee1696dc05c865f3bc726c9..bab90083f88895cd8fc8b713733c8f318ac76c6a 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 718a15a51068f46b96b6bb30fc4b1bbc6d3d020b..d87a0c4499fef86c8a49316b96c71e6c174e84ab 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'