Commit 994bed54 authored by Edward Lesmes's avatar Edward Lesmes Committed by LUCI CQ

Fix Python3 integer division issue in roll-dep.

Change-Id: I43d1b9cecee3066c206b2cfdb2fa9d37bc5001e5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2132232Reviewed-by: 's avatarEdward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
parent 4f30cf01
......@@ -134,7 +134,7 @@ def generate_commit_message(
if len(cleaned_lines) > log_limit:
# Keep the first N/2 log entries and last N/2 entries.
lines = logs.splitlines(True)
lines = lines[:log_limit/2] + ['(...)\n'] + lines[-log_limit/2:]
lines = lines[:log_limit//2] + ['(...)\n'] + lines[-log_limit//2:]
logs = ''.join(lines)
log_section += logs
return header + log_section
......
......@@ -146,6 +146,38 @@ class RollDepTest(fake_repos.FakeReposTestBase):
self.assertIn(expected_message, stdout)
self.assertIn(expected_message, commit_message)
def testRollsDepLogLimit(self):
if not self.enabled:
return
stdout, stderr, returncode = self.call(
[ROLL_DEP, 'src/foo', '--log-limit', '1'])
expected_revision = self.githash('repo_2', 3)
self.assertEqual(stderr, '')
self.assertEqual(returncode, 0)
with open(os.path.join(self.src_dir, 'DEPS')) as f:
contents = f.read()
self.assertEqual(self.gitrevparse(self.foo_dir), expected_revision)
self.assertEqual([
'deps = {',
' "src/foo": "file:///' + self.git_base.replace('\\', '\\\\') +
'repo_2@' + expected_revision + '",',
'}',
'hooks = [',
' {"action": ["foo", "--android", "{checkout_android}"]}',
']',
], contents.splitlines())
commit_message = self.call(['git', 'log', '-n', '1'])[0]
expected_message = 'Roll src/foo/ %s..%s (2 commits)' % (
self.githash('repo_2', 1)[:9], self.githash('repo_2', 3)[:9])
self.assertIn(expected_message, stdout)
self.assertIn(expected_message, commit_message)
if __name__ == '__main__':
level = logging.DEBUG if '-v' in sys.argv else logging.FATAL
......
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