diff options
author | Christopher Baines <mail@cbaines.net> | 2018-06-28 19:12:17 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2018-06-28 19:12:17 +0100 |
commit | a2e0b3fe4751dce20168ea3d7a480aed8527b870 (patch) | |
tree | ad150dfd9b9205a8065d29ad4c259f50a6570695 /app | |
parent | 373f1d131aebd9dc9c7cc6cf22a9f615627f2eef (diff) | |
download | govuk-mini-environment-admin-a2e0b3fe4751dce20168ea3d7a480aed8527b870.tar govuk-mini-environment-admin-a2e0b3fe4751dce20168ea3d7a480aed8527b870.tar.gz |
Make the git gem optional
As it's not required or useful currently if Guix isn't available
locally.
Diffstat (limited to 'app')
-rw-r--r-- | app/jobs/govuk_guix/fetch_revision_job.rb | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/app/jobs/govuk_guix/fetch_revision_job.rb b/app/jobs/govuk_guix/fetch_revision_job.rb index d3f11bf..8d77761 100644 --- a/app/jobs/govuk_guix/fetch_revision_job.rb +++ b/app/jobs/govuk_guix/fetch_revision_job.rb @@ -18,8 +18,6 @@ # License along with the GOV.UK Mini Environment Admin. If not, see # <http://www.gnu.org/licenses/>. -require 'git' - class GovukGuix::FetchRevisionJob < Que::Job extend EnqueuedJobs include ::ShellUtils @@ -82,8 +80,19 @@ class GovukGuix::FetchRevisionJob < Que::Job run_remotely_on_host: remote_host ) else + require 'git' + @repository_directory = 'tmp/cache/govuk-guix' + repository = if File.exist? @repository_directory + Git.open(@repository_directory, log: Rails.logger) + else + Git.clone( + self.class.repository_remote_location, + @repository_directory + ) + end + repository.fetch sha = repository.object(commit_hash).sha @@ -92,16 +101,6 @@ class GovukGuix::FetchRevisionJob < Que::Job end end - def repository - @_repository ||= begin - if File.exist? @repository_directory - Git.open(@repository_directory, log: Rails.logger) - else - Git.clone(self.class.repository_remote_location, @repository_directory) - end - end - end - def available_services(store_path) command_output = run_command( "#{store_path}/bin/govuk", |