Skip to content
Snippets Groups Projects
Commit 14798b8e authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

symbolize keys for Gitlab::Git::Diff & Gitlab::Git::Commit

parent d7d8edf3
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -25,7 +25,7 @@ module Gitlab
end
 
def serialize_keys
%w(id authored_date committed_date author_name author_email committer_name committer_email message parent_ids)
@serialize_keys ||= %w(id authored_date committed_date author_name author_email committer_name committer_email message parent_ids).map(&:to_sym)
end
 
def sha
Loading
Loading
@@ -116,8 +116,10 @@ module Gitlab
end
 
def init_from_hash(hash)
raw_commit = hash.symbolize_keys
serialize_keys.each do |key|
send(:"#{key}=", hash[key])
send(:"#{key}=", raw_commit[key.to_sym])
end
end
end
Loading
Loading
Loading
Loading
@@ -14,7 +14,7 @@ module Gitlab
# Stats properties
attr_accessor :new_file, :renamed_file, :deleted_file
 
def initialize(raw_diff, head = nil)
def initialize(raw_diff)
raise "Nil as raw diff passed" unless raw_diff
 
if raw_diff.is_a?(Hash)
Loading
Loading
@@ -22,12 +22,10 @@ module Gitlab
else
init_from_grit(raw_diff)
end
@head = head
end
 
def serialize_keys
%w(diff new_path old_path a_mode b_mode new_file renamed_file deleted_file)
@serialize_keys ||= %w(diff new_path old_path a_mode b_mode new_file renamed_file deleted_file).map(&:to_sym)
end
 
def to_hash
Loading
Loading
@@ -53,8 +51,10 @@ module Gitlab
end
 
def init_from_hash(hash)
raw_diff = hash.symbolize_keys
serialize_keys.each do |key|
send(:"#{key}=", hash[key])
send(:"#{key}=", raw_diff[key.to_sym])
end
end
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment