mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Revert every commit made while sleep-deprived
JFC, I have no sense of boundaries when exhausted. Reverts:6669270e84[CRAP: part Ⅱ] Reverts:13f83372a2[@vmg decides] Reverts:4fadaf80e0[CRAP: part Ⅰ] ... which are all moot points, since this is a topic-branch that's being squash-merged, and this commit exists only for @lildude's sick amusement (and the off-chance parts of it are worth salvaging).
This commit is contained in:
@@ -1,7 +1,21 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require "optparse"
|
||||
require_relative "./helpers/submodule"
|
||||
|
||||
ROOT = File.expand_path "../../", __FILE__
|
||||
|
||||
|
||||
# Extract and sort a list of submodules
|
||||
def sort_entries(file_data)
|
||||
submodules = []
|
||||
file_data.scan(/(^\[submodule[^\n]+\n)((?:\t[^\n]+\n)+)/).each do |head, body|
|
||||
path = body.match(/^\tpath\s*=\s*\K(.+)$/)[0]
|
||||
submodules << [path, head + body]
|
||||
end
|
||||
submodules.sort! { |a,b| a[0] <=> b[0] }
|
||||
submodules.collect { |i| i[1] }
|
||||
end
|
||||
|
||||
|
||||
usage = <<-EOH
|
||||
Usage:
|
||||
@@ -14,7 +28,6 @@ Examples:
|
||||
EOH
|
||||
|
||||
$testing = false
|
||||
|
||||
OptionParser.new do |opts|
|
||||
opts.banner = usage
|
||||
opts.on("-h", "--help") do
|
||||
@@ -26,11 +39,12 @@ OptionParser.new do |opts|
|
||||
end
|
||||
end.parse!
|
||||
|
||||
unsorted = read ".gitmodules"
|
||||
sorted = Submodule.list.join
|
||||
|
||||
unsorted = File.read("#{ROOT}/.gitmodules")
|
||||
sorted = sort_entries(unsorted).join
|
||||
|
||||
if $testing
|
||||
exit unsorted == sorted
|
||||
else
|
||||
write ".gitmodules", sorted
|
||||
File.write "#{ROOT}/.gitmodules", sorted
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user