diff options
author | Sebastian Ziebell <sebastian.ziebell@asquera.de> | 2013-03-05 22:29:49 +0100 |
---|---|---|
committer | Sebastian Ziebell <sebastian.ziebell@asquera.de> | 2013-03-05 22:29:49 +0100 |
commit | 61cfa2a7a6e1d4557b69e17c537656e8a0201ac8 (patch) | |
tree | f868b5a1d870a42afe57e2b4dbbf35c9445c002b /app/models/graph/commit.rb | |
parent | d269d107d86c600ab2add651f47cced8f601ae84 (diff) | |
parent | 6beae84ea37e03e68affd2b69fba25f45a4e5386 (diff) | |
download | gitlab-ce-61cfa2a7a6e1d4557b69e17c537656e8a0201ac8.tar.gz |
Merge branch 'master' into fixes/api
Conflicts:
lib/api/projects.rb
Diffstat (limited to 'app/models/graph/commit.rb')
-rw-r--r-- | app/models/graph/commit.rb | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/app/models/graph/commit.rb b/app/models/graph/commit.rb new file mode 100644 index 00000000000..8ed61f4b5af --- /dev/null +++ b/app/models/graph/commit.rb @@ -0,0 +1,59 @@ +require "grit" + +module Graph + class Commit + include ActionView::Helpers::TagHelper + + attr_accessor :time, :spaces, :refs, :parent_spaces, :icon + + def initialize(commit) + @_commit = commit + @time = -1 + @spaces = [] + @parent_spaces = [] + 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, + icon: icon + } + h[:time] = time + h[:space] = spaces.first + h[:parent_spaces] = parent_spaces + 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 + + def space + if @spaces.size > 0 + @spaces.first + else + 0 + end + end + end +end |