(input_api, output_api)
| 365 | _UPDATE_NODE_DEPENDENCIES_FOOTER = 'Update-Node-Dependencies' |
| 366 | |
| 367 | def CheckNodeModules(input_api, output_api): |
| 368 | files = ['.clang-format', 'OWNERS', 'README.chromium'] |
| 369 | results = [] |
| 370 | for file in files: |
| 371 | file_path = input_api.os_path.join(input_api.PresubmitLocalPath(), |
| 372 | 'node_modules', file) |
| 373 | if not Path(file_path).is_file(): |
| 374 | results.extend([ |
| 375 | output_api.PresubmitError( |
| 376 | "node_modules/%s is missing. Use `npm run install-deps` to re-create it." |
| 377 | % file) |
| 378 | ]) |
| 379 | |
| 380 | node_module_files = _GetAffectedFiles(input_api, [ |
| 381 | input_api.os_path.join(input_api.PresubmitLocalPath(), 'node_modules') |
| 382 | ], [], []) |
| 383 | |
| 384 | if len(node_module_files) == 0: |
| 385 | return results |
| 386 | |
| 387 | reasons = input_api.change.GitFootersFromDescription().get( |
| 388 | _UPDATE_NODE_DEPENDENCIES_FOOTER, []) |
| 389 | |
| 390 | if len(reasons): |
| 391 | if ''.join(reasons).strip() == '': |
| 392 | return [ |
| 393 | output_api.PresubmitError( |
| 394 | '{key} is specified without the reason. Please provide the reason ' |
| 395 | 'in "{key}: <reason>"'.format( |
| 396 | key=_UPDATE_NODE_DEPENDENCIES_FOOTER)) |
| 397 | ] |
| 398 | input_api.logging.info('node_modules check is being ignored') |
| 399 | return [] |
| 400 | |
| 401 | # Fail on CQ when checking diffs. |
| 402 | # Warn locally or when checking the whole tree (due to legacy headers). |
| 403 | if input_api.is_committing and not input_api.no_diffs: |
| 404 | report_type = output_api.PresubmitError |
| 405 | else: |
| 406 | report_type = output_api.PresubmitPromptWarning |
| 407 | |
| 408 | message = ( |
| 409 | "{key}: <reason> footer must be present.\n".format( |
| 410 | key=_UPDATE_NODE_DEPENDENCIES_FOOTER) + |
| 411 | "This is third party code and should not be modified manually.\n" + |
| 412 | "`node_modules` are mainly used in testing infra\n" + |
| 413 | "For bug fixes and features usually you should not need this change.\n" |
| 414 | + "Was this change intentional?") |
| 415 | |
| 416 | results.extend([report_type(message)]) |
| 417 | |
| 418 | return results |
| 419 | |
| 420 | |
| 421 | def CheckNoUncheckedFiles(input_api, output_api): |
nothing calls this directly
no test coverage detected