0
CW = ENV['TM_SUPPORT_PATH'] + '/bin/CommitWindow.app/Contents/MacOS/CommitWindow'
0
+
require LIB_ROOT + '/partial_commit_worker.rb'0
class CommitController < ApplicationController
0
@@ -23,68 +23,21 @@ class CommitController < ApplicationController
0
- def ok_to_proceed_with_partial_commit?
0
- (! git.branch.current_name.nil?) || git.initial_commit_pending?
0
- unless ok_to_proceed_with_partial_commit?
0
- render "not_on_a_branch"
0
- target_file_or_dir = git.paths.first
0
- if params[:type] == "amend"
0
- puts "Amending the commit"
0
- puts "Committing Files"
0
- puts " in ‘#{htmlize(shorten(target_file_or_dir, ENV['TM_PROJECT_DIRECTORY'] || @base))}’ on branch ‘#{htmlize(git.branch.current_name)}’</h1>"
0
+ puts "<h2>#{commit_worker.title}</h2>"
0
- files, statuses = [], []
0
- git.status(target_file_or_dir).each do |e|
0
- files << e_sh(shorten(e[:path], @base))
0
- statuses << e_sh(e[:status][:short])
0
- puts (git.clean_directory? ? "Working directory is clean (nothing to commit)" : "No changes to commit within the current scope. (Try selecting the root folder in the project drawer?)")
0
- msg, files = show_commit_dialog(files, statuses)
0
- git.auto_add_rm(files)
0
- res = git.commit(msg, files, :amend => (params[:type] == "amend"))
0
- render "_commit_result", :locals => { :files => files, :message => msg, :result => res}
0
+ result = commit_worker.run
0
+ render "_commit_result", :locals => result if result
0
+ rescue PartialCommitWorker::NotOnBranchException
0
+ render "not_on_a_branch"
0
+ rescue PartialCommitWorker::NothingToCommitException
0
+ puts(git.clean_directory? ? "Working directory is clean (nothing to commit)" : "No changes to commit within the current scope. (Try selecting the root folder in the project drawer?)")
0
+ rescue PartialCommitWorker::CommitCanceledException
0
+ puts "<strong>Canceled</strong>"
0
- def show_commit_dialog(files, statuses)
0
- status_helper_tool = ENV['TM_BUNDLE_SUPPORT'] + '/gateway/commit_dialog_helper.rb'
0
- --diff-cmd '#{git.git},diff' \
0
- --action-cmd "M,D:Revert,#{status_helper_tool},revert" \
0
- --status #{statuses.join ':'} \
0
- #{files.join ' '} 2>/dev/console
0
- puts "<strong>Cancel</strong>"
0
- res = Shellwords.shellwords(res)
0
+ @commit_worker ||= PartialCommitWorker.factory(params[:type], git)
0
\ No newline at end of file
Comments
No one has commented yet.