Class: UpdateRepo::GitControl
- Inherits:
-
Object
- Object
- UpdateRepo::GitControl
- Includes:
- Helpers
- Defined in:
- lib/update_repo/git_control.rb
Overview
Class : GitControl. This class will update one git repo, and send the output to the logger. It will also return status of the operation in #status.
Instance Attribute Summary collapse
-
#status ⇒ hash
readonly
Return the status hash.
Instance Method Summary collapse
-
#initialize(repo, logger, metrics) ⇒ void
constructor
Constructor for the GitControl class.
-
#update ⇒ void
Update the git repo that was specified in the initializer.
Methods included from Helpers
Constructor Details
#initialize(repo, logger, metrics) ⇒ void
Constructor for the GitControl class.
22 23 24 25 26 27 |
# File 'lib/update_repo/git_control.rb', line 22 def initialize(repo, logger, metrics) @status = { updated: false, failed: false, unchanged: false } @repo = repo @log = logger @metrics = metrics end |
Instance Attribute Details
#status ⇒ hash (readonly)
Return the status hash
13 14 15 |
# File 'lib/update_repo/git_control.rb', line 13 def status @status end |
Instance Method Details
#update ⇒ void
This method returns an undefined value.
Update the git repo that was specified in the initializer.
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/update_repo/git_control.rb', line 32 def update print_log '* Checking ', Dir.pwd.green, " (#{repo_url})\n" Open3.popen3('git pull') do |stdin, stdout, stderr, thread| stdin.close do_threads(stdout, stderr) thread.join end # reset the updated status in the rare case than both update and failed # are set. This does happen! @status[:updated] = false if @status[:updated] && @status[:failed] end |