From 51c167554cf492be98cecad182a6870cd6febb82 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 1 Apr 2013 16:02:54 +0300 Subject: [PATCH] added Gitlab::Git::Blame for git blame feature --- lib/gitlab/git/blame.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 lib/gitlab/git/blame.rb diff --git a/lib/gitlab/git/blame.rb b/lib/gitlab/git/blame.rb new file mode 100644 index 00000000..d6e988b6 --- /dev/null +++ b/lib/gitlab/git/blame.rb @@ -0,0 +1,22 @@ +module Gitlab + module Git + class Blame + + attr_accessor :repository, :sha, :path + + def initialize(repository, sha, path) + @repository, @sha, @path = repository, sha, path + + end + + def each + raw_blame = Grit::Blob.blame(repository.repo, sha, path) + + raw_blame.each do |commit, lines| + commit = Gitlab::Git::Commit.new(commit) + yield(commit, lines) + end + end + end + end +end