Changeset 8772
- Timestamp:
- 02/02/08 02:55:14 (5 months ago)
- Files:
-
- trunk/railties/CHANGELOG (modified) (1 diff)
- trunk/railties/lib/rails_generator/commands.rb (modified) (5 diffs)
- trunk/railties/lib/rails_generator/options.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/railties/CHANGELOG
r8629 r8772 1 1 *SVN* 2 3 * Git support for script/generate. #10690 [ssoroka] 2 4 3 5 * Update scaffold to use labels instead of bold tags. Closes #10757 [zach-inglis-lt3] trunk/railties/lib/rails_generator/commands.rb
r8615 r8772 256 256 end 257 257 258 # Optionally add file to subversion 258 # Optionally add file to subversion or git 259 259 system("svn add #{destination}") if options[:svn] 260 system("git add -v #{relative_destination}") if options[:git] 260 261 end 261 262 … … 304 305 305 306 # Create a directory including any missing parent directories. 306 # Always directories which exist.307 # Always skips directories which exist. 307 308 def directory(relative_path) 308 309 path = destination_path(relative_path) … … 313 314 unless options[:pretend] 314 315 FileUtils.mkdir_p(path) 316 # git doesn't require adding the paths, adding the files later will 317 # automatically do a path add. 315 318 316 319 # Subversion doesn't do path adds, so we need to add … … 429 432 # has no modifications so we can simply remove it 430 433 system("svn rm #{destination}") 431 end 434 end 435 elsif options[:git] 436 if options[:git][:new][relative_destination] 437 # file has been added, but not committed 438 system("git reset HEAD #{relative_destination}") 439 FileUtils.rm(destination) 440 elsif options[:git][:modified][relative_destination] 441 # file is committed and modified 442 system("git rm -f #{relative_destination}") 443 else 444 # If the directory is not in the status list, it 445 # has no modifications so we can simply remove it 446 system("git rm #{relative_destination}") 447 end 432 448 else 433 449 FileUtils.rm(destination) … … 466 482 system("svn rm #{path}") 467 483 end 484 # I don't think git needs to remove directories?.. 485 # or maybe they have special consideration... 468 486 else 469 487 FileUtils.rmdir(path) trunk/railties/lib/rails_generator/options.rb
r4502 r8772 137 137 end 138 138 end 139 opt.on('-g', '--git', 'Modify files with git. (Note: git must be in path)') do 140 options[:git] = `git status`.inject({:new => {}, :modified => {}}) do |opt, e| 141 opt[:new][e.chomp[14..-1]] = true if e =~ /new file:/ 142 opt[:modified][e.chomp[14..-1]] = true if e =~ /modified:/ 143 opt 144 end 145 end 139 146 end 140 147