Skip to content
Permalink
Browse files

Translation screenshot presubmit: Ignore nonexistent files for remove…

…d strings

The presubmit for translation screenshots asks the user to remove screenshots
associated with any strings they removed. This CL checks if the screenshot
exists before asking the user to remove it.

Bug: 924795
Change-Id: I811fe4f3d14ae5448b3dbf87aa0fc0055ec09ce8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1834277
Commit-Queue: Mustafa Emre Acer <meacer@chromium.org>
Reviewed-by: Jochen Eisinger <jochen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#702089}
  • Loading branch information
meacer authored and Commit Bot committed Oct 2, 2019
1 parent 21362da commit e7be753b99037df4fa8f666c7496ca05c4412541
Showing with 5 additions and 1 deletion.
  1. +1 −1 PRESUBMIT.py
  2. +4 −0 PRESUBMIT_test.py
@@ -4610,7 +4610,7 @@ def _CheckScreenshotAdded(screenshots_dir, message_id):
def _CheckScreenshotRemoved(screenshots_dir, message_id):
sha1_path = input_api.os_path.join(
screenshots_dir, message_id + '.png.sha1')
if sha1_path not in removed_paths:
if input_api.os_path.exists(sha1_path) and sha1_path not in removed_paths:
unnecessary_sha1_files.append(sha1_path)


@@ -2301,6 +2301,10 @@ class TranslationScreenshotsTest(unittest.TestCase):
def makeInputApi(self, files):
input_api = MockInputApi()
input_api.files = files
# Override os_path.exists because the presubmit uses the actual
# os.path.exists.
input_api.CreateMockFileInPath(
[x.LocalPath() for x in input_api.AffectedFiles(include_deletes=True)])
return input_api

def testNoScreenshots(self):

0 comments on commit e7be753

Please sign in to comment.
You can’t perform that action at this time.