Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tidy: Check Cargo.lock for packages with same version and different sources #14715

Merged
merged 2 commits into from Dec 26, 2016
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Next

Tidy: Simplify path normalization

  • Loading branch information
UK992 committed Dec 26, 2016
commit 5bd53af960638b1cf2a7c89d3d97280fea208dfa
@@ -33,10 +33,10 @@
"lint-scripts": [],
"ignore": {
"files": [
"./.", # ignore hidden files
os.path.join(".", "."), # ignore hidden files
],
"directories": [
"./.", # ignore hidden directories
os.path.join(".", "."), # ignore hidden directories
],
"packages": [],
},
@@ -90,6 +90,10 @@ def is_iter_empty(iterator):
return False, iterator


def normilize_paths(paths):
return [os.path.join(*path.split('/')) for path in paths]


# A simple wrapper for iterators to show progress
# (Note that it's inefficient for giant iterators, since it iterates once to get the upper bound)
def progress_wrapper(iterator):
@@ -123,11 +127,9 @@ def _git_changed_files(self):
args = ["git", "log", "-n1", "--merges", "--format=%H"]
last_merge = subprocess.check_output(args).strip()
args = ["git", "diff", "--name-only", last_merge, self.directory]
file_list = subprocess.check_output(args)
file_list = normilize_paths(subprocess.check_output(args).splitlines())

for f in file_list.splitlines():
if sys.platform == 'win32':
os.path.join(*f.split('/'))
for f in file_list:
if not any(os.path.join('.', os.path.dirname(f)).startswith(path) for path in self.excluded):
yield os.path.join('.', f)

@@ -862,23 +864,17 @@ def parse_config(content):
config_file = toml.loads(content)
exclude = config_file.get("ignore", {})
# Add list of ignored directories to config
config["ignore"]["directories"] += exclude.get("directories", [])
config["ignore"]["directories"] += normilize_paths(exclude.get("directories", []))
# Add list of ignored files to config
config["ignore"]["files"] += exclude.get("files", [])
config["ignore"]["files"] += normilize_paths(exclude.get("files", []))
# Add list of ignored packages to config
config["ignore"]["packages"] = exclude.get("packages", [])
# Fix the paths (OS-dependent)
config['ignore']['files'] = map(lambda path: os.path.join(*path.split('/')),
config['ignore']['files'])
config['ignore']['directories'] = map(lambda path: os.path.join(*path.split('/')),
config['ignore']['directories'])

# Add dict of dir, list of expected ext to config
dirs_to_check = config_file.get("check_ext", {})
# Fix the paths (OS-dependent)
for path, exts in dirs_to_check.items():
fixed_path = os.path.join(*path.split('/'))
config['check_ext'][fixed_path] = exts
config['check_ext'][normilize_paths([path])[0]] = exts

# Override default configs
user_configs = config_file.get("configs", [])
@@ -59,4 +59,4 @@ directories = [
# Directories that are checked for correct file extension
[check_ext]
# directory, list of expected file extensions
"components/script/dom/webidls" = [".webidl"]
"./components/script/dom/webidls" = [".webidl"]
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.