예제 #1
0
파일: fix_style.py 프로젝트: bigrpg/cef
def fix_style(filenames, white_list=None, black_list=None):
    """ Execute clang-format with the specified arguments. """
    if not white_list:
        white_list = DEFAULT_LINT_WHITELIST_REGEX
    white_regex = re.compile(white_list)
    if not black_list:
        black_list = DEFAULT_LINT_BLACKLIST_REGEX
    black_regex = re.compile(black_list)

    for filename in filenames:
        if filename.find('*') > 0:
            # Expand wildcards.
            filenames.extend(get_files(filename))
            continue

        if os.path.isdir(filename):
            # Add directory contents.
            filenames.extend(get_files(os.path.join(filename, "*")))
            continue

        if not os.path.exists(filename):
            files = get_changed_files(".", filename)
            if len(files) > 0:
                filenames.extend(files)
            else:
                msg(filename, "missing")
            continue

        if white_regex.match(filename):
            if black_regex.match(filename):
                msg(filename, "ignored")
            else:
                update_file(filename)
        else:
            msg(filename, "skipped")
예제 #2
0
    def get_cef_branch_version_components(self):
        """ Computes the CEF branch version. """
        if not bool(self._branch_version):
            minor = 0
            bugfix = 0

            # Retrieve the list of commits that have been applied on the current
            # branch since branching from origin/master.
            hashes = git.get_branch_hashes(self.cef_path)
            for hash in hashes:
                # Determine if the API hash file was modified by the commit.
                found = False
                files = git.get_changed_files(self.cef_path, hash)
                for file in files:
                    if file.find('cef_api_hash.h') >= 0:
                        found = True
                        break

                if found:
                    minor += 1
                    bugfix = 0
                else:
                    bugfix += 1

            self._branch_version = {'MINOR': minor, 'PATCH': bugfix}
        return self._branch_version
예제 #3
0
파일: fix_style.py 프로젝트: NexMirror/cef
def fix_style(filenames, white_list=None, black_list=None):
  """ Execute clang-format with the specified arguments. """
  if not white_list:
    white_list = DEFAULT_LINT_WHITELIST_REGEX
  white_regex = re.compile(white_list)
  if not black_list:
    black_list = DEFAULT_LINT_BLACKLIST_REGEX
  black_regex = re.compile(black_list)

  for filename in filenames:
    # Ignore files from specific directories.
    ignore = False
    for dir_part in filename.split(os.sep):
      if dir_part in IGNORE_DIRECTORIES:
        msg(filename, "ignored")
        ignore = True
        break
    if ignore:
      continue

    if filename.find('*') > 0:
      # Expand wildcards.
      filenames.extend(get_files(filename))
      continue

    if os.path.isdir(filename):
      # Add directory contents.
      filenames.extend(get_files(os.path.join(filename, "*")))
      continue

    if not os.path.exists(filename):
      files = get_changed_files(".", filename)
      if len(files) > 0:
        filenames.extend(files)
      else:
        msg(filename, "missing")
      continue

    if white_regex.match(filename):
      if black_regex.match(filename):
        msg(filename, "ignored")
      else:
        update_file(filename)
    else:
      msg(filename, "skipped")
예제 #4
0
    # * Disable the 'build/class' test because it errors uselessly with C
    #   structure pointers and template declarations.
    # * Disable the 'runtime/references' test because CEF allows non-const
    #   arguments passed by reference.
    # * Disable the 'runtime/sizeof' test because it has a high number of
    #   false positives and adds marginal value.
    '--filter=-build/class,-runtime/references,-runtime/sizeof',
  ]

  # Add anything passed on the command-line.
  args += sys.argv[1:]

  # Pre-process the arguments before passing to the linter.
  new_args = []
  changed = []
  for arg in args:
    if arg == '--changed':
      # Add any changed files.
      changed = git.get_changed_files(cef_dir)
    elif arg[:2] == '--' or not os.path.isdir(arg):
      # Pass argument unchanged.
      new_args.append(arg)
    else:
      # Add all files in the directory.
      new_args += get_files(os.path.join(arg, '*'))

  if len(changed) > 0:
    new_args += changed

  check_style(new_args)
예제 #5
0
        # * Disable the 'build/class' test because it errors uselessly with C
        #   structure pointers and template declarations.
        # * Disable the 'runtime/references' test because CEF allows non-const
        #   arguments passed by reference.
        # * Disable the 'runtime/sizeof' test because it has a high number of
        #   false positives and adds marginal value.
        '--filter=-build/class,-runtime/references,-runtime/sizeof',
    ]

    # Add anything passed on the command-line.
    args += sys.argv[1:]

    # Pre-process the arguments before passing to the linter.
    new_args = []
    changed = []
    for arg in args:
        if arg == '--changed':
            # Add any changed files.
            changed = git.get_changed_files(cef_dir)
        elif arg[:2] == '--' or not os.path.isdir(arg):
            # Pass argument unchanged.
            new_args.append(arg)
        else:
            # Add all files in the directory.
            new_args += get_files(os.path.join(arg, '*'))

    if len(changed) > 0:
        new_args += changed

    check_style(new_args)
예제 #6
0
파일: check_style.py 프로젝트: 02N/cef3
def get_changed_files():
  """ Retrieve the list of changed files. """
  try:
    return svn.get_changed_files(cef_dir)
  except:
    return git.get_changed_files(cef_dir)
예제 #7
0
def get_changed_files():
    """ Retrieve the list of changed files. """
    try:
        return svn.get_changed_files(cef_dir)
    except:
        return git.get_changed_files(cef_dir)