-
Notifications
You must be signed in to change notification settings - Fork 159
Display line diffs in dsl --verify error messages
#2592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,6 +1,8 @@ | ||||||||||||||||||||||||||||||||||||||
| # typed: strict | ||||||||||||||||||||||||||||||||||||||
| # frozen_string_literal: true | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| require "open3" | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| module Tapioca | ||||||||||||||||||||||||||||||||||||||
| # @requires_ancestor: Thor::Shell | ||||||||||||||||||||||||||||||||||||||
| # @requires_ancestor: SorbetHelper | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -137,6 +139,29 @@ def validate_rbi_files(command:, gem_dir:, dsl_dir:, auto_strictness:, gems: [], | |||||||||||||||||||||||||||||||||||||
| Kernel.raise Tapioca::Error, error_messages.join("\n") if parse_errors.any? | ||||||||||||||||||||||||||||||||||||||
| end | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| #: (Pathname filename, Pathname | String old_path, Pathname | String new_path) -> String | ||||||||||||||||||||||||||||||||||||||
| def file_diff(filename, old_path, new_path) | ||||||||||||||||||||||||||||||||||||||
| filename = filename.to_s | ||||||||||||||||||||||||||||||||||||||
| stdout, stderr, status = Open3.capture3( | ||||||||||||||||||||||||||||||||||||||
| "diff", | ||||||||||||||||||||||||||||||||||||||
| "-u", | ||||||||||||||||||||||||||||||||||||||
| "--label=Current #{filename}", | ||||||||||||||||||||||||||||||||||||||
| old_path.to_s, | ||||||||||||||||||||||||||||||||||||||
| "--label=Correct #{filename} (After running `bin/tapioca dsl`)", | ||||||||||||||||||||||||||||||||||||||
| new_path.to_s, | ||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+145
to
+152
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can also use the
Suggested change
Example: $ diff -u --label="before" <(echo "hello") --label "after" <(echo "world")
--- before
+++ after
@@ -1 +1 @@
-hello
+world
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice ! |
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| unless [0, 1].include?(status.exitstatus) | ||||||||||||||||||||||||||||||||||||||
| say_error("Failed to create #{filename} diff. #{stderr.chomp}", :red) | ||||||||||||||||||||||||||||||||||||||
| return "" | ||||||||||||||||||||||||||||||||||||||
| end | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| stdout | ||||||||||||||||||||||||||||||||||||||
| rescue => e | ||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What are we aiming to rescue here, exactly? |
||||||||||||||||||||||||||||||||||||||
| say_error("Failed to create #{filename} diff. #{e.message}", :red) | ||||||||||||||||||||||||||||||||||||||
| "" | ||||||||||||||||||||||||||||||||||||||
| end | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| private | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| #: (RBI::Index index, Array[String] files, number_of_workers: Integer?) -> void | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of skipping it completely should we display the diff until
@max_diff_lines?