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