Class: GitLab::Monitor::Git
- Inherits:
-
Object
- Object
- GitLab::Monitor::Git
- Defined in:
- lib/gitlab_monitor/git.rb
Overview
Git monitoring helping class
Takes a repository path for construction and provides 2 main methods:
- pull
- push
Both methods return a CommandResult which includes the output of the execution plus the tracked execution time.
Instance Method Summary collapse
- #empty_commit(message = "Beep") ⇒ Object
-
#initialize(repo) ⇒ Git
constructor
A new instance of Git.
- #pull ⇒ Object
- #push ⇒ Object
Constructor Details
#initialize(repo) ⇒ Git
Returns a new instance of Git.
14 15 16 17 18 |
# File 'lib/gitlab_monitor/git.rb', line 14 def initialize(repo) fail "Repository #{repo} does not exists" unless Dir.exist? repo @repo = repo @tracker = TimeTracker.new end |
Instance Method Details
#empty_commit(message = "Beep") ⇒ Object
29 30 31 |
# File 'lib/gitlab_monitor/git.rb', line 29 def empty_commit( = "Beep") @tracker.track { execute("git commit --allow-empty -m '#{}'") } end |
#pull ⇒ Object
20 21 22 |
# File 'lib/gitlab_monitor/git.rb', line 20 def pull @tracker.track { execute "git pull -q" } end |
#push ⇒ Object
24 25 26 27 |
# File 'lib/gitlab_monitor/git.rb', line 24 def push empty_commit @tracker.track { execute "git push -q" } end |