def _is_asset_path_modified()

in tools/validator.py [0:0]


def _is_asset_path_modified(file_path: str) -> bool:
  """Returns True if the asset-path tag has been added or modified."""
  git_diff = subprocess.Popen(["git", "diff", "origin/master", file_path],
                              stdout=subprocess.PIPE)
  grep_asset_path = subprocess.Popen(["grep", "+<!-- asset-path:"],
                                     stdin=git_diff.stdout,
                                     stdout=subprocess.PIPE,
                                     stderr=subprocess.PIPE)
  git_diff.stdout.close()
  grep_asset_path.communicate()
  return_code = grep_asset_path.returncode
  # grep exits with code 1 if it cannot find "+<!-- asset-path" in `git diff`.
  # Raise an error if the exit code is not 0 or 1.
  if return_code == 0:
    return True
  elif return_code == 1:
    return False
  else:
    raise MarkdownDocumentationError(
        f"Internal: grep command returned unexpected exit code {return_code}")