Sha256: d69079464b789e7160fd80d55a8db8955d7ddadaaccc71669686fd02c68e1f2a

Contents?: true

Size: 1.24 KB

Versions: 9

Compression:

Stored size: 1.24 KB

Contents

require 'yaml'

module Vendorificator
  class Commit
    attr_reader :git, :rev

    # Public: Initializes the object
    #
    # rev - The String containing revision expression for this commit.
    # git - The MiniGit instance to use.
    #
    # Returns Commit object.
    def initialize(rev, git)
      @rev = rev
      @git = git
    end

    # Public: Finds branches that contain this commit.
    #
    # Returns Array of branch names.
    def branches
      git.capturing.branch({:contains => true}, rev).split("\n").map do |name|
        name.tr('*', '').strip
      end
    end

    # Public: Checks if such a commit exists in the repository.
    #
    # Returns Boolean.
    def exists?
      git.capturing.rev_parse rev
      true
    rescue MiniGit::GitError
      false
    end

    # Public: Returns vendorificator git notes for the commit.
    #
    # Returns the notes Hash.
    def notes
      YAML.load(git.capturing.notes({:ref => 'vendor'}, 'show', rev))
    end

    # Public: Returns vendorificator git notes for the commit if it exists.
    #
    # Returns the notes Hash or an empty one.
    def notes?
      if exists?
        YAML.load(git.capturing.notes({:ref => 'vendor'}, 'show', rev))
      else
        {}
      end
    end

  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
vendorificator-0.6.0 lib/vendorificator/commit.rb
vendorificator-0.5.3 lib/vendorificator/commit.rb
vendorificator-0.5.2 lib/vendorificator/commit.rb
vendorificator-0.5.1 lib/vendorificator/commit.rb
vendorificator-0.5.0 lib/vendorificator/commit.rb
vendorificator-0.5.git.v0.4.0.63.g8e9d54d lib/vendorificator/commit.rb
vendorificator-0.5.git.v0.4.0.60.g9c35209 lib/vendorificator/commit.rb
vendorificator-0.5.git.v0.4.0.17.g26d50d8 lib/vendorificator/commit.rb
vendorificator-0.4.0 lib/vendorificator/commit.rb