Commit 6c13d84f authored by Eduardo Bonet's avatar Eduardo Bonet

Logging more info

parent 440a62cb
...@@ -122,22 +122,18 @@ class BlobPresenter < Gitlab::View::Presenter::Delegated ...@@ -122,22 +122,18 @@ class BlobPresenter < Gitlab::View::Presenter::Delegated
def transformed_blob_data def transformed_blob_data
@transformed_blob ||= if blob.path.ends_with?('.ipynb') @transformed_blob ||= if blob.path.ends_with?('.ipynb')
begin
new_blob = IpynbDiff.transform(blob.data, new_blob = IpynbDiff.transform(blob.data,
raise_errors: true, raise_errors: true,
options: { include_metadata: false, cell_decorator: :percent }) options: { include_metadata: false, cell_decorator: :percent })
rescue IpynbDiff::InvalidNotebookError => e
Gitlab::ErrorTracking.track_and_raise_for_dev_exception(e, issue_url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/344676')
return blob.data
end
if new_blob Gitlab::AppLogger.info(new_blob ? 'IPYNBDIFF_BLOB_GENERATED' : 'IPYNBDIFF_BLOB_NIL')
Gitlab::AppLogger.info('IPYNBDIFF_BLOB_GENERATED')
new_blob new_blob
else
Gitlab::AppLogger.info('IPYNBDIFF_BLOB_NIL')
blob.data
end
end end
@transformed_blob ||= blob.data
rescue IpynbDiff::InvalidNotebookError => e
Gitlab::ErrorTracking.track_and_raise_for_dev_exception(e, issue_url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/344676')
blob.data
end end
end end
...@@ -456,22 +456,19 @@ module Gitlab ...@@ -456,22 +456,19 @@ module Gitlab
from = old_blob_lazy&.data from = old_blob_lazy&.data
to = new_blob_lazy&.data to = new_blob_lazy&.data
begin
new_diff = IpynbDiff.diff(from, to, new_diff = IpynbDiff.diff(from, to,
diff_opts: { context: 5, include_diff_info: true }, diff_opts: { context: 5, include_diff_info: true },
transform_options: { cell_decorator: :percent }, transform_options: { cell_decorator: :percent },
raise_if_invalid_notebook: true) raise_if_invalid_notebook: true)
if new_diff diff.diff = new_diff.scan(/.*\n/)[2..-1].join('') if new_diff
diff.diff = new_diff.scan(/.*\n/)[2..-1].join('')
Gitlab::AppLogger.info("IPYNB_DIFF_GENERATED") Gitlab::AppLogger.info({ message: new_diff ? 'IPYNB_DIFF_GENERATED' : 'IPYNB_DIFF_NIL',
else from: from&.to_s, to: to&.to_s })
Gitlab::AppLogger.info("IPYNB_DIFF_NIL")
end
rescue IpynbDiff::InvalidNotebookError => e rescue IpynbDiff::InvalidNotebookError => e
Gitlab::ErrorTracking.track_and_raise_for_dev_exception(e, issue_url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/344676') Gitlab::ErrorTracking.track_and_raise_for_dev_exception(e, issue_url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/344676')
end end
end
def alternate_viewer_class def alternate_viewer_class
return unless viewer.instance_of?(DiffViewer::Renamed) return unless viewer.instance_of?(DiffViewer::Renamed)
......
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