mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Rake test:uncommitted finds git directory in ancestors.
Sometimes your git directory is an ancestor of your application root directory. For example: ./repo/.git/ ./repo/app/Rakefile In this case rake test:uncommitted will be unable to detect your SCM. This patch fixes this and add a test.
This commit is contained in:
parent
8ec51669d4
commit
df822961ee
2 changed files with 30 additions and 1 deletions
|
@ -88,7 +88,7 @@ namespace :test do
|
|||
def t.file_list
|
||||
if File.directory?(".svn")
|
||||
changed_since_checkin = silence_stderr { `svn status` }.split.map { |path| path.chomp[7 .. -1] }
|
||||
elsif File.directory?(".git")
|
||||
elsif system "git rev-parse --git-dir 2>&1 >/dev/null"
|
||||
changed_since_checkin = silence_stderr { `git ls-files --modified --others --exclude-standard` }.split.map { |path| path.chomp }
|
||||
else
|
||||
abort "Not a Subversion or Git checkout."
|
||||
|
|
|
@ -106,6 +106,35 @@ module ApplicationTests
|
|||
end
|
||||
end
|
||||
|
||||
def test_rake_test_uncommitted_always_find_git_in_parent_dir
|
||||
app_name = File.basename(app_path)
|
||||
app_dir = File.dirname(app_path)
|
||||
moved_app_name = app_name + '_moved'
|
||||
moved_app_path = "#{app_path}/#{moved_app_name}"
|
||||
|
||||
Dir.chdir(app_dir) do
|
||||
# Go from "./app/" to "./app/app_moved"
|
||||
FileUtils.mv(app_name, moved_app_name)
|
||||
FileUtils.mkdir(app_name)
|
||||
FileUtils.mv(moved_app_name, app_name)
|
||||
# Initialize the git repository and start the test.
|
||||
Dir.chdir(app_name) do
|
||||
`git init`
|
||||
Dir.chdir(moved_app_name){ `rake db:migrate` }
|
||||
silence_stderr { Dir.chdir(moved_app_name) { `rake test:uncommitted` } }
|
||||
assert_equal 0, $?.exitstatus
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_rake_test_uncommitted_fails_with_no_scm
|
||||
Dir.chdir(app_path){ `rake db:migrate` }
|
||||
Dir.chdir(app_path) do
|
||||
silence_stderr { `rake test:uncommitted` }
|
||||
assert_equal 1, $?.exitstatus
|
||||
end
|
||||
end
|
||||
|
||||
def test_rake_routes_calls_the_route_inspector
|
||||
app_file "config/routes.rb", <<-RUBY
|
||||
AppTemplate::Application.routes.draw do
|
||||
|
|
Loading…
Reference in a new issue