Class: GitLab::Exporter::Git
- Inherits:
-
Object
- Object
- GitLab::Exporter::Git
- Defined in:
- lib/gitlab_exporter/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 19 |
# File 'lib/gitlab_exporter/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
30 31 32 |
# File 'lib/gitlab_exporter/git.rb', line 30 def empty_commit( = "Beep") @tracker.track { execute("git commit --allow-empty -m '#{}'") } end |
#pull ⇒ Object
21 22 23 |
# File 'lib/gitlab_exporter/git.rb', line 21 def pull @tracker.track { execute "git pull -q" } end |
#push ⇒ Object
25 26 27 28 |
# File 'lib/gitlab_exporter/git.rb', line 25 def push empty_commit @tracker.track { execute "git push -q" } end |