28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/bones/app/git.rb', line 28
def initialize_git
return unless @config[:git]
File.rename('.bnsignore', '.gitignore') if test ?f, '.bnsignore'
author = Git.global_config['user.name']
email = Git.global_config['user.email']
if test ?f, 'Rakefile'
lines = File.readlines 'Rakefile'
lines.each do |line|
case line
when %r/^\s*authors\s+/
line.replace " authors '#{author}'" unless author.nil? or line !~ %r/FIXME/
when %r/^\s*email\s+/
line.replace " email '#{email}'" unless email.nil? or line !~ %r/FIXME/
when %r/^\s*url\s+/
next unless @config[:github]
url = github_url
line.replace " url '#{url}'" unless url.nil? or line !~ %r/FIXME/
when %r/^\s*\}\s*$/
line.insert 0, " ignore_file '.gitignore'\n" if test ?f, '.gitignore'
end
end
File.open('Rakefile', 'w') {|fd| fd.puts lines}
end
@git = Git.init
@git.add
@git.commit "Initial commit to #{name}."
end
|