fixes after review
This commit is contained in:
		
							parent
							
								
									5df2c4419c
								
							
						
					
					
						commit
						3c97cbc74c
					
				|  | @ -135,7 +135,7 @@ class Commit | ||||||
|     description.present? |     description.present? | ||||||
|   end |   end | ||||||
| 
 | 
 | ||||||
|   def hook_attrs(with_changed_files = false) |   def hook_attrs(with_changed_files: false) | ||||||
|     path_with_namespace = project.path_with_namespace |     path_with_namespace = project.path_with_namespace | ||||||
| 
 | 
 | ||||||
|     data = { |     data = { | ||||||
|  | @ -150,11 +150,7 @@ class Commit | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if with_changed_files |     if with_changed_files | ||||||
|       data.merge!({ |       data.merge!(repo_changes) | ||||||
|         added: repo_changes[:added], |  | ||||||
|         modified: repo_changes[:modified], |  | ||||||
|         removed: repo_changes[:removed] |  | ||||||
|       }) |  | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     data |     data | ||||||
|  | @ -212,18 +208,15 @@ class Commit | ||||||
|   def repo_changes |   def repo_changes | ||||||
|     changes = { added: [], modified: [], removed: [] } |     changes = { added: [], modified: [], removed: [] } | ||||||
| 
 | 
 | ||||||
|     if diffs.any? |  | ||||||
|     diffs.each do |diff| |     diffs.each do |diff| | ||||||
|         case true |       if diff.deleted_file | ||||||
|         when diff.deleted_file |  | ||||||
|         changes[:removed] << diff.old_path |         changes[:removed] << diff.old_path | ||||||
|         when diff.renamed_file, diff.new_file |       elsif diff.renamed_file || diff.new_file | ||||||
|         changes[:added] << diff.new_path |         changes[:added] << diff.new_path | ||||||
|       else |       else | ||||||
|         changes[:modified] << diff.new_path |         changes[:modified] << diff.new_path | ||||||
|       end |       end | ||||||
|     end |     end | ||||||
|     end |  | ||||||
| 
 | 
 | ||||||
|     changes |     changes | ||||||
|   end |   end | ||||||
|  |  | ||||||
|  | @ -31,7 +31,7 @@ module Gitlab | ||||||
|         # For performance purposes maximum 20 latest commits |         # For performance purposes maximum 20 latest commits | ||||||
|         # will be passed as post receive hook data. |         # will be passed as post receive hook data. | ||||||
|         commit_attrs = commits_limited.map do |commit| |         commit_attrs = commits_limited.map do |commit| | ||||||
|           commit.hook_attrs(true) |           commit.hook_attrs(with_changed_files: true) | ||||||
|         end |         end | ||||||
| 
 | 
 | ||||||
|         type = Gitlab::Git.tag_ref?(ref) ? "tag_push" : "push" |         type = Gitlab::Git.tag_ref?(ref) ? "tag_push" : "push" | ||||||
|  |  | ||||||
|  | @ -102,7 +102,7 @@ eos | ||||||
|   end |   end | ||||||
| 
 | 
 | ||||||
|   describe '#hook_attrs' do |   describe '#hook_attrs' do | ||||||
|     let(:data) { commit.hook_attrs(true) } |     let(:data) { commit.hook_attrs(with_changed_files: true) } | ||||||
| 
 | 
 | ||||||
|     it { expect(data).to be_a(Hash) } |     it { expect(data).to be_a(Hash) } | ||||||
|     it { expect(data[:message]).to include('Add submodule from gitlab.com') } |     it { expect(data[:message]).to include('Add submodule from gitlab.com') } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue