Welcome to mirror list, hosted at ThFree Co, Russian Federation.

commit.rb « graph « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a6bf23a2381899c396895c7ee101bd4eb948aa49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
require "grit"

module Gitlab
  module Graph
    class Commit
      include ActionView::Helpers::TagHelper

      attr_accessor :time, :space, :refs

      def initialize(commit)
        @_commit = commit
        @time = -1
        @space = 0
      end

      def method_missing(m, *args, &block)
        @_commit.send(m, *args, &block)
      end

      def to_graph_hash
        h = {}
        h[:parents] = self.parents.collect do |p|
          [p.id,0,0]
        end
        h[:author]  = {
          name: author.name, 
          email: author.email
        }
        h[:time]    = time
        h[:space]   = space
        h[:refs]    = refs.collect{|r|r.name}.join(" ") unless refs.nil?
        h[:id]      = sha
        h[:date]    = date
        h[:message] = message
        h
      end

      def add_refs(ref_cache, repo)
        if ref_cache.empty?
          repo.refs.each do |ref|
            ref_cache[ref.commit.id] ||= []
            ref_cache[ref.commit.id] << ref
          end
        end
        @refs = ref_cache[@_commit.id] if ref_cache.include?(@_commit.id)
        @refs ||= []
      end
    end
  end
end