From abbb81a85138f1f42fa357468bd03f58e584c724 Mon Sep 17 00:00:00 2001
From: Arnaud Levy <contact@arnaudlevy.com>
Date: Tue, 16 May 2023 17:30:38 +0200
Subject: [PATCH] Code Climate

---
 app/services/git/analyzer.rb   | 9 +++++++++
 app/services/git/repository.rb | 5 ++---
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/app/services/git/analyzer.rb b/app/services/git/analyzer.rb
index cbc3eb234..bc943b684 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 ff2c32b81..5ccb56b74 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
-- 
GitLab