Adjust fsmonitor alert for Mac

Version 2.43 contains a fix for fsmonitor. Google managed git already
contains the fix.

R=aravindvasudev

Fixed: 1475405
Change-Id: I388b1e14e070595b8b0c6bca046dd3af2248a0ae
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4892305
Auto-Submit: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>
Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com>
changes/05/4892305/2
Josip Sokcevic 1 year ago committed by LUCI CQ
parent 0827dd28f1
commit d95084e851

@ -423,6 +423,13 @@ def warn_submodule():
# TODO(crbug.com/1475405): Warn users if the project uses submodules and
# they have fsmonitor enabled.
if sys.platform.startswith('darwin') and is_fsmonitor_enabled():
version_string = run('--version')
if version_string.endswith('goog'):
return
version_tuple = _extract_git_tuple(version_string)
if version_tuple >= (2, 43):
return
print(colorama.Fore.RED)
print('WARNING: You have fsmonitor enabled. There is a major issue '
'resulting in git diff-index returning wrong results. Please '
@ -1119,6 +1126,10 @@ def get_git_version():
"""Returns a tuple that contains the numeric components of the current git
version."""
version_string = run('--version')
return _extract_git_tuple(version_string)
def _extract_git_tuple(version_string):
version_match = re.search(r'(\d+.)+(\d+)', version_string)
version = version_match.group() if version_match else ''

@ -16,6 +16,9 @@ import tempfile
import time
import unittest
from io import StringIO
from unittest import mock
DEPOT_TOOLS_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, DEPOT_TOOLS_ROOT)
@ -1131,6 +1134,38 @@ class GitTestUtilsTest(git_test_utils.GitRepoReadOnlyTestBase):
self.repo.show_commit('C', format_string='%cn %ce %ci'))
class WarnSubmoduleTest(unittest.TestCase):
def setUp(self):
import git_common
self.warn_submodule = git_common.warn_submodule
mock.patch('sys.stdout', StringIO()).start()
def testWarnFSMonitorOldVersion(self):
mock.patch('git_common.is_fsmonitor_enabled', lambda: True).start()
mock.patch('sys.platform', 'darwin').start()
mock.patch('git_common.run', lambda _: 'git version 2.40.0').start()
self.warn_submodule()
self.assertTrue('WARNING: You have fsmonitor enabled.' in \
sys.stdout.getvalue())
def testWarnFSMonitorNewVersion(self):
mock.patch('git_common.is_fsmonitor_enabled', lambda: True).start()
mock.patch('sys.platform', 'darwin').start()
mock.patch('git_common.run', lambda _: 'git version 2.43.1').start()
self.warn_submodule()
self.assertFalse('WARNING: You have fsmonitor enabled.' in \
sys.stdout.getvalue())
def testWarnFSMonitorGoogVersion(self):
mock.patch('git_common.is_fsmonitor_enabled', lambda: True).start()
mock.patch('sys.platform', 'darwin').start()
mock.patch('git_common.run',
lambda _: 'git version 2.42.0.515.A-goog').start()
self.warn_submodule()
self.assertFalse('WARNING: You have fsmonitor enabled.' in \
sys.stdout.getvalue())
if __name__ == '__main__':
sys.exit(
coverage_utils.covered_main(

Loading…
Cancel
Save