mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Fix various syntax and logic errors
This commit is contained in:
@@ -43,13 +43,21 @@ def log(msg)
|
|||||||
puts msg if $verbose
|
puts msg if $verbose
|
||||||
end
|
end
|
||||||
|
|
||||||
|
$aborted = false
|
||||||
|
|
||||||
def command(*args)
|
def command(*args)
|
||||||
log "$ #{args.join(' ')}"
|
log "$ #{args.join(' ')}"
|
||||||
output, status = Open3.capture2e(*args)
|
output, status = Open3.capture2e(*args)
|
||||||
if !status.success?
|
if !status.success?
|
||||||
|
output = output.each_line { |line| " > #{line}" }
|
||||||
|
unless $aborted
|
||||||
|
$aborted = true
|
||||||
warn "Command failed. Aborting."
|
warn "Command failed. Aborting."
|
||||||
error.output = output.each_line { |line| " > #{line}" }
|
raise output
|
||||||
raise { output: output, status: status }
|
else
|
||||||
|
warn output
|
||||||
|
exit 1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -101,28 +109,28 @@ begin
|
|||||||
|
|
||||||
# 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]}"
|
||||||
repo_new = "vendor/grammars/#{parts[:repo]}"
|
$repo_new = "vendor/grammars/#{parts[:repo]}"
|
||||||
repo_old = parse_submodule($replace) if $replace
|
$repo_old = parse_submodule($replace) if $replace
|
||||||
|
|
||||||
Dir.chdir(ROOT)
|
Dir.chdir(ROOT)
|
||||||
|
|
||||||
if repo_old
|
if $repo_old
|
||||||
log "Deregistering: #{repo_old}"
|
log "Deregistering: #{$repo_old}"
|
||||||
command('git', 'submodule', 'deinit', repo_old)
|
command('git', 'submodule', 'deinit', $repo_old)
|
||||||
command('git', 'rm', '-rf', repo_old)
|
command('git', 'rm', '-rf', $repo_old)
|
||||||
command('script/grammar-compiler', 'update', '-f')
|
command('script/grammar-compiler', 'update', '-f')
|
||||||
end
|
end
|
||||||
|
|
||||||
log "Registering new submodule: #{repo_new}"
|
log "Registering new submodule: #{$repo_new}"
|
||||||
command('git', 'submodule', 'add', '-f', https, repo_new)
|
command('git', 'submodule', 'add', '-f', $https, $repo_new)
|
||||||
command('script/grammar-compiler', 'add', repo_new)
|
command('script/grammar-compiler', 'add', $repo_new)
|
||||||
|
|
||||||
log "Confirming license"
|
log "Confirming license"
|
||||||
if repo_old
|
if $repo_old
|
||||||
command('script/licensed')
|
command('script/licensed')
|
||||||
else
|
else
|
||||||
command('script/licensed', '--module', repo_new)
|
command('script/licensed', '--module', $repo_new)
|
||||||
end
|
end
|
||||||
|
|
||||||
log "Updating grammar documentation in vendor/README.md"
|
log "Updating grammar documentation in vendor/README.md"
|
||||||
@@ -130,17 +138,21 @@ begin
|
|||||||
command('script/sort-submodules')
|
command('script/sort-submodules')
|
||||||
command('script/list-grammars')
|
command('script/list-grammars')
|
||||||
rescue => ex
|
rescue => ex
|
||||||
if repo_new
|
log ex
|
||||||
`git submodule deinit #{repo_new}`
|
if $repo_new
|
||||||
`rm -rf #{repo_new}`
|
`git reset HEAD .gitmodules #{$repo_new}`
|
||||||
`rm -rf .git/modules/#{repo_new}/`
|
`git checkout -- vendor/licenses`
|
||||||
|
`rm -rf #{$repo_new}`
|
||||||
|
`rm -rf .git/modules/#{$repo_new}/`
|
||||||
restore_configs()
|
restore_configs()
|
||||||
end
|
end
|
||||||
if repo_old
|
if $repo_old
|
||||||
`rm -rf #{repo_old}`
|
`rm -rf #{$repo_old}`
|
||||||
`git submodule add -f "#{https}", "#{repo_old}"`
|
`git submodule add -f "#{$https}", "#{$repo_old}"`
|
||||||
restore_configs()
|
restore_configs()
|
||||||
end
|
end
|
||||||
File.write("#{ROOT}/vendor/README.md", $vendor_list)
|
File.write("#{ROOT}/vendor/README.md", $vendor_list)
|
||||||
|
`git reset HEAD vendor/licenses`
|
||||||
|
`git checkout -- vendor/licenses`
|
||||||
exit 1
|
exit 1
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user