summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorZeger-Jan van de Weg <git@zjvandeweg.nl>2018-07-19 10:37:46 +0200
committerZeger-Jan van de Weg <git@zjvandeweg.nl>2018-07-19 13:34:10 +0200
commitcfbb256b8b755e84f8156bc01bc1ba278eeaafa9 (patch)
tree5a9b7cb5ee5d218bdf7f1490b2009f12d037ff69 /db
parent928c81e2598da2a114011549b7aa68fce85fd077 (diff)
downloadgitlab-ce-cfbb256b8b755e84f8156bc01bc1ba278eeaafa9.tar.gz
MigrateProcessCommitWorkerJobs to use Gitaly
This old migration used Rugged to find a commit, while Gitaly is the prefered way now. By migrating this to Gitaly, Gitaly is now a required running component for this migration. Part of https://gitlab.com/gitlab-org/gitaly/issues/1106
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb54
1 files changed, 27 insertions, 27 deletions
diff --git a/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb b/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb
index dc16d5c5169..1eb6a8fa5df 100644
--- a/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb
+++ b/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb
@@ -1,9 +1,19 @@
-# See http://doc.gitlab.com/ce/development/migration_style_guide.html
-# for more information on how to write migrations for GitLab.
-
class MigrateProcessCommitWorkerJobs < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
+ class Repository
+ attr_reader :storage
+
+ def initialize(storage, relative_path)
+ @storage = storage
+ @relative_path = relative_path
+ end
+
+ def gitaly_repository
+ Gitaly::Repository.new(storage_name: @storage, relative_path: @relative_path)
+ end
+ end
+
class Project < ActiveRecord::Base
def self.find_including_path(id)
select("projects.*, CONCAT(namespaces.path, '/', projects.path) AS path_with_namespace")
@@ -11,19 +21,12 @@ class MigrateProcessCommitWorkerJobs < ActiveRecord::Migration
.find_by(id: id)
end
- def repository_storage_path
- Gitlab::GitalyClient::StorageSettings.allow_disk_access do
- Gitlab.config.repositories.storages[repository_storage].legacy_disk_path
- end
- end
-
- def repository_path
- # TODO: review if the change from Legacy storage needs to reflect here as well.
- File.join(repository_storage_path, read_attribute(:path_with_namespace) + '.git')
+ def commit(rev)
+ Gitlab::GitalyClient::CommitService.new(repository).find_commit(rev)
end
def repository
- @repository ||= Rugged::Repository.new(repository_path)
+ @repository ||= Repository.new(repository_storage, read_attribute(:path_with_namespace) + '.git')
end
end
@@ -42,22 +45,19 @@ class MigrateProcessCommitWorkerJobs < ActiveRecord::Migration
next unless project
- begin
- commit = project.repository.lookup(payload['args'][2])
- rescue Rugged::OdbError
- next
- end
+ commit = project.commit(payload['args'][2])
+ next unless commit
hash = {
- id: commit.oid,
- message: encode(commit.message),
- parent_ids: commit.parent_ids,
- authored_date: commit.author[:time],
- author_name: encode(commit.author[:name]),
- author_email: encode(commit.author[:email]),
- committed_date: commit.committer[:time],
- committer_email: encode(commit.committer[:email]),
- committer_name: encode(commit.committer[:name])
+ id: commit.id,
+ message: encode(commit.body),
+ parent_ids: commit.parent_ids.to_a,
+ authored_date: Time.at(commit.author.date.seconds).utc,
+ author_name: encode(commit.author.name),
+ author_email: encode(commit.author.email),
+ committed_date: Time.at(commit.committer.date.seconds).utc,
+ committer_email: encode(commit.committer.email),
+ committer_name: encode(commit.committer.name)
}
payload['args'][2] = hash