Skip to content

Commit

Permalink
Git Init option for app init now works, with added ability to commit …
Browse files Browse the repository at this point in the history
…as well. [#25 state:resolved]
  • Loading branch information
mtodd committed May 7, 2008
1 parent 1da1bf7 commit 464942b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lib/halcyon/runner/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ def console(argv)

# Generate a new Halcyon application
def init(argv)
app_name = argv.last

options = {
:generator => 'halcyon',
:git => false
Expand All @@ -101,6 +103,7 @@ def init(argv)
opts.separator ""
opts.separator "Additional options:"
opts.on("-g", "--git", "Initialize a Git repository when finished generating") { options[:git] = true }
opts.on("-G", "--git-commit", "Initialize a Git repo and commit") { options[:git] = options[:git_commit] = true }

begin
opts.parse! argv
Expand All @@ -114,6 +117,21 @@ def init(argv)
RubiGen::Base.use_application_sources!
RubiGen::Base.sources << RubiGen::PathSource.new(:custom, File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', "support/generators")))
RubiGen::Scripts::Generate.new.run(argv, :generator => options[:generator])

# Create a Git repository in the new app dir
if options[:git]
system("cd #{app_name} && git init -q && cd #{Dir.pwd}")
puts "Initialized Git repository in #{app_name}/"
File.open(File.join("#{app_name}",'.gitignore'),"w") {|f| f << "log/*.log" }
File.open(File.join("#{app_name}",'log','.gitignore'),"w") {|f| f << "" }
end

# commit to the git repo
if options[:git_commit]
system("cd #{app_name} && git add . && git commit -m 'Initial import.' -q && cd #{Dir.pwd}")
puts "Committed empty application in #{app_name}/"
puts "Run `git commit --amend` to change the commit message."
end
end

end
Expand Down

0 comments on commit 464942b

Please sign in to comment.