Method: Oxidized::Git#version

Defined in:
lib/oxidized/output/git.rb

#version(node, group) ⇒ Object

give a hash of all oid revision for the given node, and the date of the commit



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/oxidized/output/git.rb', line 74

def version node, group
  begin
    repo, path = yield_repo_and_path(node, group)

    repo = Rugged::Repository.new repo
    walker = Rugged::Walker.new(repo)
    walker.sorting(Rugged::SORT_DATE)
    walker.push(repo.head.target)
    i = -1
    tab  = []
    walker.each do |commit|
      if commit.diff(paths: [path]).size > 0
        hash = {}
        hash[:date] = commit.time.to_s
        hash[:oid] = commit.oid
        hash[:author] = commit.author
        hash[:message] = commit.message
        tab[i += 1] = hash
      end
    end
    walker.reset
    tab
  rescue
    'node not found'
  end
end