Sha256: 53d0ffd356475ce7b3e40882ae582bcfe71d5d6b1d1e672c7f8454059fd72d98

Contents?: true

Size: 1.16 KB

Versions: 37

Compression:

Stored size: 1.16 KB

Contents

require_relative './scm'
require_relative '../../util'

module Builderator
  module Control
    # :nodoc:
    class Version
      ##
      # SCM implementation for Git
      ##
      module Git
        extend SCM

        COMMIT_FORMAT = /^(?<hash>[a-f0-9]+)(?:\s+\((?<tags>.+?)\))?\s+(?<message>.+)$/
        TAG_FORMAT = %r{tag: ([a-zA-Z0-9\.\-\+/_]+)}

        ## Is there a .git repo in the project root?
        def self.supported?
          Util.relative_path('.git').exist?
        end

        def self._history
          `git log --pretty='format:%H %d %s' HEAD`.chomp
            .split("\n")
            .map { |string| string.match(COMMIT_FORMAT) }
            .reject(&:nil?)
            .map do |commit|
              {
                :id => commit[:hash],
                :message => commit[:message]
              }.tap do |c|
                tag_match = commit[:tags].scan(TAG_FORMAT)
                            .flatten
                            .reject(&:nil?) unless commit[:tags].nil?

                c[:tags] = tag_match unless tag_match.nil? || tag_match.empty?
              end
            end
        end
      end

      SCM.register(Git)
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
builderator-2.0.1 lib/builderator/control/version/git.rb
builderator-2.0.0 lib/builderator/control/version/git.rb
builderator-1.3.2 lib/builderator/control/version/git.rb
builderator-1.3.1 lib/builderator/control/version/git.rb
builderator-1.3.0 lib/builderator/control/version/git.rb
builderator-1.2.3.pre.beta.1 lib/builderator/control/version/git.rb
builderator-1.2.2 lib/builderator/control/version/git.rb
builderator-1.2.1 lib/builderator/control/version/git.rb
builderator-1.2.0 lib/builderator/control/version/git.rb
builderator-1.1.12 lib/builderator/control/version/git.rb
builderator-1.1.11 lib/builderator/control/version/git.rb
builderator-1.1.10 lib/builderator/control/version/git.rb
builderator-1.1.9 lib/builderator/control/version/git.rb
builderator-1.1.8 lib/builderator/control/version/git.rb
builderator-1.1.7 lib/builderator/control/version/git.rb
builderator-1.1.6 lib/builderator/control/version/git.rb
builderator-1.1.5 lib/builderator/control/version/git.rb
builderator-1.1.4 lib/builderator/control/version/git.rb
builderator-1.1.3 lib/builderator/control/version/git.rb
builderator-1.1.2 lib/builderator/control/version/git.rb