Class: Rosette::Queuing::Commits::FetchStage

Inherits:
Stage
  • Object
show all
Defined in:
lib/rosette/queuing/commits/fetch_stage.rb

Overview

Fetches the repository. This should be the first commit processing stage since it ensures the given commit is available in the repository for processing.

See Also:

  • RepoConfig

Constant Summary

Constants inherited from Stage

Stage::PhraseStatus

Instance Attribute Summary

Attributes inherited from Stage

#commit_log, #logger, #repo_config, #rosette_config

Instance Method Summary collapse

Methods inherited from Stage

accepts, accepts?, for_commit_log, #initialize, #to_job

Constructor Details

This class inherits a constructor from Rosette::Queuing::Commits::Stage

Instance Method Details

#execute!void

This method returns an undefined value.

Executes this stage and updates the commit log with a FETCHED status. Performs a git fetch.


21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/rosette/queuing/commits/fetch_stage.rb', line 21

def execute!
  logger.info("Fetching git repository #{repo_config.name}")

  git.fetch
    .setRemote('origin')
    .setRemoveDeletedRefs(true)
    .call

  commit_log.fetch

  # git won't know about the commit before a fetch, which is why branch
  # name is set in this stage and not when the commit is first enqueued
  commit_log.branch_name = Rosette::Core::BranchUtils.derive_branch_name(
    commit_log.commit_id, repo_config.repo
  )

  save_commit_log

  logger.info("Finished fetching git repository #{repo_config.name}")
end