diff options
author | Rémy Coutable <remy@rymai.me> | 2016-12-14 09:21:28 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-12-14 09:21:28 +0000 |
commit | 78f89f7ad900ec2f2993a70caa2eb5dbf9e2496f (patch) | |
tree | 2a776d2cb8be3b161457c4e1cbb6729e3f85f901 /db | |
parent | c6d7785976bf84518e098cc168847e3e4e7e6386 (diff) | |
parent | 43af4e5577e5ea338ea5cf072cd0635e3dabcc9e (diff) | |
download | gitlab-ce-78f89f7ad900ec2f2993a70caa2eb5dbf9e2496f.tar.gz |
Merge branch 'process-commit-worker-migration-encoding' into 'master'
Encode when migrating ProcessCommitWorker jobs
## What does this MR do?
This adds encoding logic to the migration for ProcessCommitWorker, ensuring it doesn't throw errors when the input can not be converted to UTF-8 without extra help.
## What are the relevant issue numbers?
https://gitlab.com/gitlab-org/gitlab-ce/issues/25489
See merge request !8064
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb b/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb index 453a44e271a..77e0c40d850 100644 --- a/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb +++ b/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb @@ -47,14 +47,14 @@ class MigrateProcessCommitWorkerJobs < ActiveRecord::Migration hash = { id: commit.oid, - message: commit.message, + message: encode(commit.message), parent_ids: commit.parent_ids, authored_date: commit.author[:time], - author_name: commit.author[:name], - author_email: commit.author[:email], + author_name: encode(commit.author[:name]), + author_email: encode(commit.author[:email]), committed_date: commit.committer[:time], - committer_email: commit.committer[:email], - committer_name: commit.committer[:name] + committer_email: encode(commit.committer[:email]), + committer_name: encode(commit.committer[:name]) } payload['args'][2] = hash @@ -89,4 +89,14 @@ class MigrateProcessCommitWorkerJobs < ActiveRecord::Migration end end end + + def encode(data) + encoding = Encoding::UTF_8 + + if data.encoding == encoding + data + else + data.encode(encoding, invalid: :replace, undef: :replace) + end + end end |