aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/jobs/govuk_guix/fetch_revision_job.rb23
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",