Class: Gitlab::Git::GitStats

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab_git/git_stats.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repo, ref) ⇒ GitStats

Returns a new instance of GitStats.



8
9
10
# File 'lib/gitlab_git/git_stats.rb', line 8

def initialize repo, ref
  @repo, @ref = repo, ref
end

Instance Attribute Details

#ref ⇒ Object

Returns the value of attribute ref.



6
7
8
# File 'lib/gitlab_git/git_stats.rb', line 6

def ref
  @ref
end

#repo ⇒ Object

Returns the value of attribute repo.



6
7
8
# File 'lib/gitlab_git/git_stats.rb', line 6

def repo
  @repo
end

Instance Method Details

#log ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/gitlab_git/git_stats.rb', line 12

def log
  log = nil
  Grit::Git.with_timeout(30) do
    # Limit log to 6k commits to avoid timeout for huge projects
    args = [ref, '-6000', '--format=%aN%x0a%aE%x0a%cd', '--date=short', '--shortstat', '--no-merges', '--diff-filter=ACDM']
    log = repo.git.run(nil, 'log', nil, {}, args)
  end

  log
rescue Grit::Git::GitTimeout
  nil
end

#parsed_log ⇒ Object



25
26
27
# File 'lib/gitlab_git/git_stats.rb', line 25

def parsed_log
  LogParser.parse_log(log)
end