Commit 6d4d139d authored by Florent Didier's avatar Florent Didier

Revert "[dev] wiki_generator.rb: add different exit codes when exception occurs"

This reverts commit d7b89dfa.
parent b98e0a61
......@@ -34,13 +34,13 @@ class WikiGenerator
diff = Diffy::Diff.new(wiki_content, generated_content, :context => 0)
if (diff.to_s.empty?)
puts "No differences found between generated and current wiki content for page #{@page_name}."
return 0
return true
end
puts "Differences between generated and current wiki content for page #{@page_name}:"
puts '------------ PAGE DIFF BEGIN ------------'
puts "#{diff.to_s(:text)}"
puts '------------- PAGE DIFF END -------------'
return 1
return false
end
def remove_page_creation_date(content)
......@@ -54,7 +54,7 @@ class WikiGenerator
end
def diff_files
ret = 0
ret = true
@files.each { |file|
if file['content-type'] == 'text/plain'
file_content = @mw_client.get_file_content(file['filename'])
......@@ -62,13 +62,13 @@ class WikiGenerator
diff = Diffy::Diff.new(file_content, generated_content, :context => 0)
if (diff.to_s.empty?)
puts "No differences found between generated and current content for file #{file['filename']}."
ret &= 0
ret &= true
else
puts "Differences between generated and current content for file #{file['filename']}:"
puts '------------ FILE DIFF BEGIN ------------'
puts "#{diff.to_s(:text)}"
puts '------------- FILE DIFF END -------------'
ret &= 1
ret &= false
end
end
}
......@@ -134,37 +134,25 @@ class WikiGenerator
#Execute actions on generator based on given options
def self.exec(generator, options)
ret = 2
begin
generator.generate_content()
#Login only if we need to
if (options[:diff] || options[:update])
generator.login(options)
ret = 0
end
if (options[:diff])
ret = generator.diff_page if generator.instance_variable_get('@generated_content')
ret &= generator.diff_files if generator.instance_variable_get('@files')
end
if (options[:print])
generator.print
ret = 0
end
if (options[:update])
generator.update_page if generator.instance_variable_get('@generated_content')
generator.update_files if generator.instance_variable_get('@files')
ret = 0
end
rescue MediawikiApi::ApiError => e
puts e
ret = 3
rescue StandardError => e
puts e
ret = 4
end
exit ret
generator.generate_content()
ret = true
#Login only if we need to
if (options[:diff] || options[:update])
generator.login(options)
end
if (options[:diff])
ret &= generator.diff_page if generator.instance_variable_get('@generated_content')
ret &= generator.diff_files if generator.instance_variable_get('@files')
end
if (options[:print])
generator.print
end
if (options[:update])
generator.update_page if generator.instance_variable_get('@generated_content')
generator.update_files if generator.instance_variable_get('@files')
end
return ret
end
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment