mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-12-08 20:38:47 +00:00
Commit in-progress work to request sanity check
This commit is contained in:
@@ -1,21 +1,7 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require "optparse"
|
||||
|
||||
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
|
||||
|
||||
require_relative "./helpers/submodule"
|
||||
|
||||
usage = <<-EOH
|
||||
Usage:
|
||||
@@ -28,6 +14,7 @@ Examples:
|
||||
EOH
|
||||
|
||||
$testing = false
|
||||
|
||||
OptionParser.new do |opts|
|
||||
opts.banner = usage
|
||||
opts.on("-h", "--help") do
|
||||
@@ -39,12 +26,11 @@ OptionParser.new do |opts|
|
||||
end
|
||||
end.parse!
|
||||
|
||||
|
||||
unsorted = File.read("#{ROOT}/.gitmodules")
|
||||
sorted = sort_entries(unsorted).join
|
||||
unsorted = read ".gitmodules"
|
||||
sorted = Submodule.list.join
|
||||
|
||||
if $testing
|
||||
exit unsorted == sorted
|
||||
else
|
||||
File.write "#{ROOT}/.gitmodules", sorted
|
||||
write ".gitmodules", sorted
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user