mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Fix the check_style.py patch_RepositoryName function to work with git.
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@468 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@ -3,7 +3,7 @@
|
|||||||
# Use of this source code is governed by a BSD-style license that can be
|
# Use of this source code is governed by a BSD-style license that can be
|
||||||
# found in the LICENSE file.
|
# found in the LICENSE file.
|
||||||
|
|
||||||
import os, re, sys
|
import os, re, string, sys
|
||||||
from file_util import *
|
from file_util import *
|
||||||
import git_util as git
|
import git_util as git
|
||||||
import svn_util as svn
|
import svn_util as svn
|
||||||
@ -43,31 +43,24 @@ except ImportError, e:
|
|||||||
# The default implementation of FileInfo.RepositoryName looks for the top-most
|
# The default implementation of FileInfo.RepositoryName looks for the top-most
|
||||||
# directory that contains a .git or .svn folder. This is a problem for CEF
|
# directory that contains a .git or .svn folder. This is a problem for CEF
|
||||||
# because the CEF root folder (which may have an arbitrary name) lives inside
|
# because the CEF root folder (which may have an arbitrary name) lives inside
|
||||||
# the Chromium src folder. Fix this problem by normalizing the top-most path
|
# the Chromium src folder. Reimplement in a dumb but sane way.
|
||||||
# component.
|
def patch_RepositoryName(self):
|
||||||
def patch_RepositoryName(func):
|
fullname = self.FullName()
|
||||||
def wrapper(self):
|
project_dir = os.path.dirname(fullname)
|
||||||
ret = func(self)
|
if os.path.exists(fullname):
|
||||||
|
root_dir = project_dir
|
||||||
pos = ret.find('/')
|
while os.path.basename(project_dir) != "src":
|
||||||
if pos < 0:
|
project_dir = os.path.dirname(project_dir)
|
||||||
pos = ret.find('\\')
|
prefix = os.path.commonprefix([root_dir, project_dir])
|
||||||
if pos < 0:
|
components = fullname[len(prefix) + 1:].split('/')
|
||||||
return ret;
|
return string.join(["cef"] + components[1:], '/')
|
||||||
|
return fullname
|
||||||
# Normalize the top-most path component.
|
|
||||||
return 'cef'+ret[pos:]
|
|
||||||
|
|
||||||
wrapper.__name__ = func.__name__
|
|
||||||
wrapper.__doc__ = func.__doc__
|
|
||||||
return wrapper
|
|
||||||
|
|
||||||
def check_style(args, white_list = None, black_list = None):
|
def check_style(args, white_list = None, black_list = None):
|
||||||
""" Execute cpplint with the specified arguments. """
|
""" Execute cpplint with the specified arguments. """
|
||||||
|
|
||||||
# Apply patches.
|
# Apply patches.
|
||||||
cpplint.FileInfo.RepositoryName = \
|
cpplint.FileInfo.RepositoryName = patch_RepositoryName
|
||||||
patch_RepositoryName(cpplint.FileInfo.RepositoryName)
|
|
||||||
|
|
||||||
# Process cpplint arguments.
|
# Process cpplint arguments.
|
||||||
filenames = cpplint.ParseArguments(args)
|
filenames = cpplint.ParseArguments(args)
|
||||||
|
Reference in New Issue
Block a user