Add logic to update submodules and licenses

This commit is contained in:
Alhadis
2016-09-07 04:25:00 +10:00
parent f382abc2f3
commit 4584963dd2
2 changed files with 31 additions and 14 deletions

View File

@@ -37,6 +37,13 @@ def parse_submodule(name)
path
end
# Print debugging feedback to STDOUT if running with --verbose
def log(msg)
puts msg if $verbose
end
usage = """Usage:
#{$0} [--replace grammar] url
Examples:
@@ -44,7 +51,6 @@ Examples:
#{$0} --replace sublime-apl https://github.com/Alhadis/language-apl
"""
$replace = nil
$verbose = false
@@ -67,19 +73,21 @@ unless $url
exit 1;
end
# Ensure the given URL is an HTTPS link
parts = parse_url $url
https = "https://#{parts[:host]}/#{parts[:user]}/#{parts[:repo]}"
path = "vendor/grammars/#{parts[:repo]}"
repl = parse_submodule($replace) if $replace
parts = parse_url $url
https = "https://#{parts[:host]}/#{parts[:user]}/#{parts[:repo]}"
repo_new = "vendor/grammars/#{parts[:repo]}"
repo_old = parse_submodule($replace) if $replace
if $verbose
puts "Adding grammar"
puts "\tFrom: #{https}"
puts "\tInto: #{path}"
puts "\tReplacing: #{repl}" if repl
puts "\nRegistering submodule..."
if repo_old
log "Deregistering: #{repo_old}"
`git submodule deinit #{repo_old}`
`git rm -rf #{repo_old}`
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}"`