Skip to content

Instantly share code, notes, and snippets.

@natanael-araujo
Last active October 24, 2017 23:46
Show Gist options
  • Save natanael-araujo/e6f9c186f50c8751e70c37fd5cbd1c08 to your computer and use it in GitHub Desktop.
Save natanael-araujo/e6f9c186f50c8751e70c37fd5cbd1c08 to your computer and use it in GitHub Desktop.
auxiliar a identificação de forks entre muitos projetos
require 'git'
# auxiliar a identificação de forks em um workspace bagunçado
mapping = Hash.new { |h, v| h[v] = [] }
Dir.glob('*/').each do |path|
last_commit = Git.open(path).log(99999).last
mapping["#{last_commit.sha[0,6]} - #{last_commit.message}"].push path
end
File.open('./projects_index', 'wb') do |file|
file.puts("Total of projects: #{mapping.values.flatten.count}\n")
mapping.each do |commit, projects|
file.puts("\nFirst commit: #{commit}")
file.puts("Total of forks: #{projects.count}")
projects.each { |project_path| file.puts("\t#{project_path.chop}") }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment