Skip to content

format: add format fix for java proto options#5516

Merged
mattklein123 merged 6 commits into
envoyproxy:masterfrom
snowp:java-opt
Jan 17, 2019
Merged

format: add format fix for java proto options#5516
mattklein123 merged 6 commits into
envoyproxy:masterfrom
snowp:java-opt

Conversation

@snowp
Copy link
Copy Markdown
Contributor

@snowp snowp commented Jan 7, 2019

Allows running tools/check_format.py fix to insert the necessary java
proto options.

Signed-off-by: Snow Pettersen snowp@squareup.com

Risk Level: Low
Testing: Added check_format_test
Docs Changes: n/a
Release Notes: n/a
Fixes #5477

Snow Pettersen added 2 commits January 7, 2019 11:15
Allows running tools/check_format.py fix to insert the necessary java
proto options.

Signed-off-by: Snow Pettersen <snowp@squareup.com>
Signed-off-by: Snow Pettersen <snowp@squareup.com>
@snowp
Copy link
Copy Markdown
Contributor Author

snowp commented Jan 7, 2019

/assign @jmarantz

@stale
Copy link
Copy Markdown

stale Bot commented Jan 14, 2019

This pull request has been automatically marked as stale because it has not had activity in the last 7 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@stale stale Bot added the stale stalebot believes this issue/PR has not been touched recently label Jan 14, 2019
@snowp
Copy link
Copy Markdown
Contributor Author

snowp commented Jan 14, 2019

@jmarantz You wanna give this one a look?

@stale stale Bot removed the stale stalebot believes this issue/PR has not been touched recently label Jan 14, 2019
Comment thread tools/check_format.py Outdated
package_name = None
for line in fileinput.FileInput(file_path):
if line.startswith("package "):
package_name = re.compile("package (.*);").search(line).group(1)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you compile the regex at global scope?

Comment thread tools/check_format_test_helper.py
infile = os.path.join(src, filename)
directory = os.path.dirname(filename)
if not directory == '' and not os.path.isdir(directory):
os.makedirs(directory)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious why this is needed. If there's a filename reaching here, shouldn't we expect the directory to exist?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the time I added it because I had issues with the fact that the test file is api/java_options.proto and requires api to exist, but seems like I can remove this and it still works.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other mkdirs is necessary though to avoid:

diff proto_format.proto /source/tools/testdata/check_format/proto_format.proto.gold
Traceback (most recent call last):
  File "./tools/check_format_test_helper.py", line 215, in <module>
    errors += checkAndFixError("api/java_options.proto", "Java proto option")
  File "./tools/check_format_test_helper.py", line 126, in checkAndFixError
    errors = checkFileExpectingError(filename, expected_substring)
  File "./tools/check_format_test_helper.py", line 121, in checkFileExpectingError
    command, status, stdout = runCheckFormat("check", getInputFile(filename))
  File "./tools/check_format_test_helper.py", line 55, in getInputFile
    shutil.copyfile(infile, filename)
  File "/usr/lib/python2.7/shutil.py", line 83, in copyfile
    with open(dst, 'wb') as fdst:
IOError: [Errno 2] No such file or directory: 'api/java_options.proto'

Signed-off-by: Snow Pettersen <snowp@squareup.com>
Comment thread tools/check_format.py Outdated
Snow Pettersen added 3 commits January 16, 2019 20:32
Signed-off-by: Snow Pettersen <snowp@squareup.com>
Signed-off-by: Snow Pettersen <snowp@squareup.com>
Signed-off-by: Snow Pettersen <snowp@squareup.com>
@mattklein123 mattklein123 merged commit f4b4fef into envoyproxy:master Jan 17, 2019
fredlas pushed a commit to fredlas/envoy that referenced this pull request Mar 5, 2019
Allows running tools/check_format.py fix to insert the necessary java
proto options.

Signed-off-by: Snow Pettersen <snowp@squareup.com>
Signed-off-by: Fred Douglas <fredlas@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add format fix for java proto options

3 participants