Sha256: 6a1ce8fe03660ee6976c2f523e706c48ed2db53d6c2d951cbc532bf2bd2428c1

Contents?: true

Size: 964 Bytes

Versions: 2

Compression:

Stored size: 964 Bytes

Contents

module VCLog

  class VCS

    ### = GIT 
    ###
    class GIT

      def initialize

      end

      #
      def changelog
        @changelog ||= generate_changelog
      end

      # 
      def generate_changelog
        log = Changelog.new

        changelog ||= `git-log`.strip

        changes = changelog.split(/^commit/m)

        changes.shift # throw the first (empty) entry away

        changes.each do |text|
          date, who, rev, msg = nil, nil, nil, []
          text.each_line do |line|
            unless rev
              rev = line.strip
              next
            end
            if md = /^Author:(.*?)$/.match(line)
              who = md[1]
            elsif md = /^Date:(.*?)$/m.match(line)
              date = Time.parse(md[1])
            else
              msg << line.strip
            end
          end
          log.change(date, who, rev, msg.join("\n"))
        end

        @changelog = log
      end

    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vclog-1.1 lib/vclog/vcs/git.rb
vclog-1.0.0 lib/vclog/vcs/git.rb