Skip to content

Commit bb32533

Browse files
committed
Fix warning with frozen string
1 parent 4ee06e6 commit bb32533

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

app/models/commit.rb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen-string-literal: true
2+
13
class Commit < ApplicationRecord
24
has_many :contributions, dependent: :destroy
35
has_many :contributors, through: :contributions
@@ -43,13 +45,13 @@ def self.import!(rugged_commit)
4345
def self.new_from_rugged_commit(rugged_commit)
4446
new(
4547
sha1: rugged_commit.oid,
46-
author_name: rugged_commit.author[:name].force_encoding('UTF-8'),
47-
author_email: rugged_commit.author[:email].force_encoding('UTF-8'),
48+
author_name: rugged_commit.author[:name].dup.force_encoding('UTF-8'),
49+
author_email: rugged_commit.author[:email].dup.force_encoding('UTF-8'),
4850
author_date: rugged_commit.author[:time],
49-
committer_name: rugged_commit.committer[:name].force_encoding('UTF-8'),
50-
committer_email: rugged_commit.committer[:email].force_encoding('UTF-8'),
51+
committer_name: rugged_commit.committer[:name].dup.force_encoding('UTF-8'),
52+
committer_email: rugged_commit.committer[:email].dup.force_encoding('UTF-8'),
5153
committer_date: rugged_commit.committer[:time],
52-
message: rugged_commit.message.force_encoding('UTF-8'),
54+
message: rugged_commit.message.dup.force_encoding('UTF-8'),
5355
merge: rugged_commit.parents.size > 1
5456
)
5557
end
@@ -196,7 +198,7 @@ def cache_diff(repo)
196198
# git show, and is an expensive operation. So, we do this only for those
197199
# commits where this is needed, and cache the result in the database.
198200
def extract_changelog
199-
changelog = ''
201+
changelog = +''
200202
in_changelog = false
201203
diff.each_line do |line|
202204
if line =~ /^diff --git/

test/models/commit_test.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen-string-literal: true
2+
13
require 'test_helper'
24
require 'ostruct'
35

0 commit comments

Comments
 (0)