Commit 61579f92e1bfc95e582728011fcd21c79f08c3ae

split up ignores

i prefer the ignore to be in separate files.
added ignore for sqlite databases.

Commit diff

lib/git-rails/commands/init.rb

 
1require 'fileutils'
2
13module GitRails
24 module Commands
35 class Init < GitRails::Command
4
56 def run(remote, message='', commit=false)
6 unless File.exists?(".gitignore")
7 gitignore = File.new(".gitignore", "w")
8 gitignore << "log/*.log\n"
9 gitignore << "tmp/**/*\n"
10 gitignore << ".DS_Store\n"
11 gitignore << "public/cache/**/*\n"
12 gitignore << "doc/api\n"
13 gitignore << "doc/app\n"
14 gitignore.close
15 end
16 FileUtils.mkdir_p("log")
17 gitignore = File.new("log/.gitignore", "w")
18 gitignore.close
19 FileUtils.mkdir_p("tmp")
20 gitignore = File.new("tmp/.gitignore", "w")
21 gitignore.close
22
7 ignore(".", ".DS_Store")
8 ignore("config", "database.yml")
9 ignore("db", ["*.db", "*.sqlite*"])
10 ignore("log", "*.log")
11 ignore("tmp", "[^.]*")
12 ignore("public/cache", "[^.]*")
13 ignore("doc", ["api","app"])
14
2315 git = GitRails::Git.new
2416 git.init
2517 git.add(".")
2929 puts " git push origin master\n"
3030 end
3131 end
32
32 private
33 def ignore(path, entries)
34 file = path + "/.gitignore"
35 unless File.exists?(file)
36 FileUtils.mkdir_p(path)
37 handle = File.new(file, "w")
38 entries.each do |entry|
39 handle << "#{entry}\n"
40 end
41 handle.close
42 end
43 end
3344 end
3445 end
3546end
toggle raw diff