mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
superproject: Log syncstate's parameter as data-json it it is an array.
All the values of syncstate are strings, check the first byte and last byte to see if it is an array. For syncstate data, there were no false positives. Tested: $ repo_dev sync Verified event logged for argv is "data-json". $./run_tests Bug: [google internal] b/201102002 Change-Id: Id56adb532b80267f08d09147ac663cdd5987ce87 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/319075 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Raman Tenneti <rtenneti@google.com>
This commit is contained in:
parent
9d96f58f5f
commit
bbe8836494
@ -167,9 +167,9 @@ class EventLog(object):
|
|||||||
repo_config = {k: v for k, v in config.items() if k.startswith('repo.')}
|
repo_config = {k: v for k, v in config.items() if k.startswith('repo.')}
|
||||||
self.LogConfigEvents(repo_config, 'def_param')
|
self.LogConfigEvents(repo_config, 'def_param')
|
||||||
|
|
||||||
def GetDataEventName(self, key):
|
def GetDataEventName(self, value):
|
||||||
"""Returns the 'data-json' if the key is argv else returns 'data'."""
|
"""Returns 'data-json' if the value is an array else returns 'data'."""
|
||||||
return 'data-json' if key.endswith('sys.argv') else 'data'
|
return 'data-json' if value[0] == '[' and value[-1] == ']' else 'data'
|
||||||
|
|
||||||
def LogDataConfigEvents(self, config, prefix):
|
def LogDataConfigEvents(self, config, prefix):
|
||||||
"""Append a 'data' event for each config key/value in |config| to the current log.
|
"""Append a 'data' event for each config key/value in |config| to the current log.
|
||||||
@ -182,7 +182,7 @@ class EventLog(object):
|
|||||||
prefix: Prefix for each key that is logged.
|
prefix: Prefix for each key that is logged.
|
||||||
"""
|
"""
|
||||||
for key, value in config.items():
|
for key, value in config.items():
|
||||||
event = self._CreateEventDict(self.GetDataEventName(key))
|
event = self._CreateEventDict(self.GetDataEventName(value))
|
||||||
event['key'] = f'{prefix}/{key}'
|
event['key'] = f'{prefix}/{key}'
|
||||||
event['value'] = value
|
event['value'] = value
|
||||||
self._log.append(event)
|
self._log.append(event)
|
||||||
|
@ -267,7 +267,7 @@ class EventLogTestCase(unittest.TestCase):
|
|||||||
self.assertIn('value', event)
|
self.assertIn('value', event)
|
||||||
key = event['key'].removeprefix(f'{prefix_value}/')
|
key = event['key'].removeprefix(f'{prefix_value}/')
|
||||||
value = event['value']
|
value = event['value']
|
||||||
self.assertEqual(self._event_log_module.GetDataEventName(key), event['event'])
|
self.assertEqual(self._event_log_module.GetDataEventName(value), event['event'])
|
||||||
self.assertTrue(key in config and value == config[key])
|
self.assertTrue(key in config and value == config[key])
|
||||||
|
|
||||||
def test_error_event(self):
|
def test_error_event(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user