Sha256: c13c85dc0abbf7e965fa6285ac2739825b0dccfbf65f4c1eaea83020a45c556e

Contents?: true

Size: 1.97 KB

Versions: 8

Compression:

Stored size: 1.97 KB

Contents

# commit_changelog.rb, part of Create-changelog
# Copyright 2015 Daniel Kraus
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
require_relative 'changelog_filter'

# Filters commit messages for changelog entries.
class CommitChangelog

	# Contains changelog entries of the commits.
	attr_reader :changelog

	# Instantiates an object containing changelog entries between
	# two git commits.
	#
	# @param [String] to_commit
	#	  Most recent commit whose changelog lines to include.
	#
	#	@param [String] from_commit
	#	  Earlier commit whose changelog lines will _not_ be included.
	#
	#	@return [Array]
	#	  Array of changelog lines, or nil if none were found.
	#
	def initialize(to_commit, from_commit)
		pattern = ChangelogFilter.pattern
		messages = Git.get_filtered_messages(from_commit, to_commit, pattern)
		filter = ChangelogFilter.FromString(messages)
		@changelog = filter.changelog
	end

	# Adds changelog information contained in a specific commit message. This
	# method is typically used to parse the initial commit's commit message.
	#
	# @param [String] commit
	#   Sha-1 of the commit whose commit message to filter for changelog lines.
	#
	# @return
	#   Undefined
	#
	def add_commit(commit)
		pattern = ChangelogFilter.pattern
		filtered_text = Git.get_filtered_message(commit, pattern)
		if filtered_text
			filtered_lines = filtered_text.split("\n").uniq
			if @changelog
				@changelog = @changelog.concat(filtered_lines).uniq
			else
				@changelog = filtered_lines
			end
		end
	end
end

# vim: nospell

Version data entries

8 entries across 6 versions & 1 rubygems

Version Path
create_changelog-1.4.3 lib/commit_changelog.rb
create_changelog-1.4.2 lib/commit_changelog.rb
create_changelog-1.4.1 lib/commit_changelog.rb
create_changelog-1.3.2 lib/commit_changelog.rb~
create_changelog-1.3.2 lib/commit_changelog.rb
create_changelog-1.3.1 lib/commit_changelog.rb~
create_changelog-1.3.1 lib/commit_changelog.rb
create_changelog-1.3.0 lib/commit_changelog.rb