Sha256: 398cac9af6d649d1e3881f80b226c11b9ee769130ead9b8a5d7719332cfd5d02
Contents?: true
Size: 1.06 KB
Versions: 1
Compression:
Stored size: 1.06 KB
Contents
# frozen_string_literal: true require 'git' module GFSM module Tools class GitUtilities CHANGELOG_TRAILER_REGEX = /^(?<name>Changelog):\s*(?<category>.+)$/i def self.load_repo(repo_path) Git.open(repo_path) end def self.extract_last_tag_name(repo) begin current_sort_order = repo.config("tag.sort") repo.config("tag.sort", "-v:refname") tags = repo.tags repo.config("tag.sort", current_sort_order) tags[0].name if !tags.empty? rescue end end def self.extract_commits_with_changelog_trailer(repo) last_tag_name = self.extract_last_tag_name(repo) begin commits = last_tag_name ? repo.log.between(last_tag_name, 'HEAD') : repo.log commits.each_with_object([]) do |commit, memo| trailer = commit.message.match(CHANGELOG_TRAILER_REGEX) memo << GFSM::Data::Commit.new(commit, trailer[:name], trailer[:category]) if trailer end rescue [] end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gfsm-0.3.1 | lib/tools/git_utilities.rb |