Use ProvidedDiffChange if diff is empty string

A ProvidedDiffChange should be able to use an diff, even if it is empty.

Bug: 372936485
Change-Id: If6bea0063e92c8942aed080e4c26b8d032b90faa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5926311
Commit-Queue: Gavin Mak <gavinmak@google.com>
Reviewed-by: Scott Lee <ddoman@chromium.org>
This commit is contained in:
Gavin Mak
2024-10-24 17:04:34 +00:00
committed by LUCI CQ
parent ecad42cb6a
commit a6ce588715
3 changed files with 2 additions and 15 deletions

View File

@@ -123,10 +123,6 @@ class TestParseDiff(unittest.TestCase):
self.assertCountEqual(content, diff)
self.assertCountEqual(change_files, expected)
def test_diff_to_change_files_raises_on_empty_file(self):
with self.assertRaises(presubmit_support.PresubmitFailure):
self._test_diff_to_change_files(diff='', expected=[])
def test_diff_to_change_files_raises_on_empty_diff_header(self):
diff = """
diff --git a/foo b/foo

View File

@@ -1097,15 +1097,6 @@ def CheckChangeOnCommit(input_api, output_api):
end_commit=options.end_commit)
scm.GIT.GetAllFiles.assert_called_once_with(options.root)
def testParseChange_EmptyDiffFile(self):
gclient_utils.FileRead.return_value = ''
options = mock.Mock(all_files=False,
files=[],
generate_diff=False,
diff_file='foo.diff')
with self.assertRaises(presubmit.PresubmitFailure):
presubmit._parse_change(None, options)
@mock.patch('presubmit_support.ProvidedDiffChange', mock.Mock())
def testParseChange_ProvidedDiffFile(self):
diff = """