mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 09:40:21 +00:00
Add logic to update submodules and licenses
This commit is contained in:
@@ -37,6 +37,13 @@ def parse_submodule(name)
|
|||||||
path
|
path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Print debugging feedback to STDOUT if running with --verbose
|
||||||
|
def log(msg)
|
||||||
|
puts msg if $verbose
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
usage = """Usage:
|
usage = """Usage:
|
||||||
#{$0} [--replace grammar] url
|
#{$0} [--replace grammar] url
|
||||||
Examples:
|
Examples:
|
||||||
@@ -44,7 +51,6 @@ Examples:
|
|||||||
#{$0} --replace sublime-apl https://github.com/Alhadis/language-apl
|
#{$0} --replace sublime-apl https://github.com/Alhadis/language-apl
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
$replace = nil
|
$replace = nil
|
||||||
$verbose = false
|
$verbose = false
|
||||||
|
|
||||||
@@ -67,19 +73,21 @@ unless $url
|
|||||||
exit 1;
|
exit 1;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
# Ensure the given URL is an HTTPS link
|
# Ensure the given URL is an HTTPS link
|
||||||
parts = parse_url $url
|
parts = parse_url $url
|
||||||
https = "https://#{parts[:host]}/#{parts[:user]}/#{parts[:repo]}"
|
https = "https://#{parts[:host]}/#{parts[:user]}/#{parts[:repo]}"
|
||||||
path = "vendor/grammars/#{parts[:repo]}"
|
repo_new = "vendor/grammars/#{parts[:repo]}"
|
||||||
repl = parse_submodule($replace) if $replace
|
repo_old = parse_submodule($replace) if $replace
|
||||||
|
|
||||||
if $verbose
|
if repo_old
|
||||||
puts "Adding grammar"
|
log "Deregistering: #{repo_old}"
|
||||||
puts "\tFrom: #{https}"
|
`git submodule deinit #{repo_old}`
|
||||||
puts "\tInto: #{path}"
|
`git rm -rf #{repo_old}`
|
||||||
puts "\tReplacing: #{repl}" if repl
|
|
||||||
puts "\nRegistering submodule..."
|
|
||||||
end
|
end
|
||||||
|
|
||||||
#`git submodule add #{https} #{path}`
|
log "Registering new submodule: #{repo_new}"
|
||||||
|
`git submodule add -f #{https} #{repo_new}`
|
||||||
|
`script/convert-grammars --add #{repo_new}`
|
||||||
|
|
||||||
|
log "Confirming license"
|
||||||
|
`script/licensed --module "#{repo_new}"`
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
require "bundler/setup"
|
require "bundler/setup"
|
||||||
require "licensed/cli"
|
require "licensed/cli"
|
||||||
|
require "optparse"
|
||||||
|
|
||||||
module Licensed
|
module Licensed
|
||||||
module Source
|
module Source
|
||||||
@@ -32,7 +33,14 @@ module Licensed
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
source = Licensed::Source::Filesystem.new("vendor/grammars/*/", type: "grammar")
|
module_path = nil
|
||||||
|
OptionParser.new do |opts|
|
||||||
|
opts.on("-mPATH", "--module=PATH", "Cache license file for specific grammar") do |p|
|
||||||
|
module_path = p
|
||||||
|
end
|
||||||
|
end.parse!
|
||||||
|
|
||||||
|
source = Licensed::Source::Filesystem.new(module_path || "vendor/grammars/*/", type: "grammar")
|
||||||
config = Licensed::Configuration.new
|
config = Licensed::Configuration.new
|
||||||
config.sources << source
|
config.sources << source
|
||||||
|
|
||||||
@@ -43,4 +51,5 @@ else
|
|||||||
end
|
end
|
||||||
|
|
||||||
command.run
|
command.run
|
||||||
|
`git checkout -- vendor/licenses/grammar/` if module_path
|
||||||
exit command.success?
|
exit command.success?
|
||||||
|
|||||||
Reference in New Issue
Block a user