Sha256: 32b2b47a144fad6764197620a379dec44bf4fccce6fd91ad72b81aec7c295a99

Contents?: true

Size: 1.33 KB

Versions: 2

Compression:

Stored size: 1.33 KB

Contents

# frozen_string_literal: true

# Released under the MIT License.
# Copyright, 2024, by Samuel Williams.

def initialize(context)
	super
	
	require "bake/modernize/license"
end

# Extract changes from a repository and generate a list of contributors.
# @parameter root [String] The root directory of the repository.
# @parameter paths [Array(String)] The paths to extract changes from.
def extract(root:, paths:)
	authorship = Bake::Modernize::License::Authorship.new
	
	authorship.extract(root)
	
	modifications = []
	
	paths.each do |path|
		authorship.paths[path].each do |modification|
			modification = modification.to_h
			
			if modification[:path] != path
				modification[:original_path] = modification[:path]
				modification[:path] = path
			end
			
			modifications << modification
		end
	end
	
	modifications.sort_by!{|modification| modification[:time]}
	
	return modifications
end

# Map the changes to a new path.
# @parameter input [Array(Hash)] The list of changes.
# @parameter original_path [String] The original path of the changes.
# @parameter path [String] The path that now contains the content of the original changes.
def map(original_path, path, input:)
	input.each do |modification|
		if modification[:path] == original_path
			modification[:original_path] = modification[:path]
			modification[:path] = path
		end
	end
	
	return input
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bake-modernize-0.31.0 bake/modernize/contributors.rb
bake-modernize-0.30.0 bake/modernize/contributors.rb