diff --git a/app/services/git/analyzer.rb b/app/services/git/analyzer.rb index cbc3eb2347138e038838cf317d3a3e2e3efc5488..bc943b6842573770d4d28d601a08641754f5af16 100644 --- a/app/services/git/analyzer.rb +++ b/app/services/git/analyzer.rb @@ -29,8 +29,17 @@ class Git::Analyzer path.nil? end + def commit_message + git_file.about.nil? ? "[#{ git_file.class.name }] #{ action } Git file" + : "[#{ git_file.about.class.name }] #{ action } #{ git_file.about }" + end + protected + def action + should_destroy? ? "Destroy" : "Save" + end + def path git_file.path end diff --git a/app/services/git/repository.rb b/app/services/git/repository.rb index ff2c32b8196df1d4b236b7418c217c3bf4789842..5ccb56b744ea25bf75136cd12b5f2563bd72d82c 100644 --- a/app/services/git/repository.rb +++ b/app/services/git/repository.rb @@ -12,10 +12,9 @@ class Git::Repository def add_git_file(git_file) puts "Adding #{git_file.path}" if git_files.empty? + # The first file gives the commit name analyzer.git_file = git_file - action = analyzer.should_destroy? ? "Destroy" : "Save" - @commit_message = git_file.about.nil? ? "[#{ git_file.class.name }] #{ action } Git file" - : "[#{ git_file.about.class.name }] #{ action } #{ git_file.about }" + @commit_message = analyzer.commit_message end git_files << git_file end