fix: deny-git-deps script for path+version deps and markdown lint
This commit is contained in:
@@ -8,6 +8,7 @@ root folder. If not provided, it will use the cwd.
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import toml
|
||||||
|
|
||||||
from cargo_workspace import Workspace, DependencyLocation
|
from cargo_workspace import Workspace, DependencyLocation
|
||||||
|
|
||||||
@@ -29,18 +30,45 @@ def check_dep(dep, used_by):
|
|||||||
else:
|
else:
|
||||||
errors.append(f'🚫 Found git dependency {dep.name} in {used_by}')
|
errors.append(f'🚫 Found git dependency {dep.name} in {used_by}')
|
||||||
|
|
||||||
# Check the workspace dependencies that can be inherited:
|
# Check the workspace dependencies directly from Cargo.toml to avoid
|
||||||
for dep in workspace.dependencies:
|
# cargo-workspace library bug with path+version combinations
|
||||||
check_dep(dep, "workspace")
|
cargo_toml_path = os.path.join(root, 'Cargo.toml')
|
||||||
|
with open(cargo_toml_path, 'r') as f:
|
||||||
|
cargo_toml = toml.load(f)
|
||||||
|
|
||||||
if workspace.crates.find_by_name(dep.name):
|
workspace_deps = cargo_toml.get('workspace', {}).get('dependencies', {})
|
||||||
if dep.location != DependencyLocation.PATH:
|
for dep_name, dep_value in workspace_deps.items():
|
||||||
errors.append(f'🚫 Workspace must use path to link local dependency {dep.name}')
|
# Check if it's a git dependency
|
||||||
|
if isinstance(dep_value, dict) and 'git' in dep_value:
|
||||||
|
if 'workspace' not in ALLOWED_GIT_DEPS.get(dep_name, []):
|
||||||
|
errors.append(f'🚫 Found git dependency {dep_name} in workspace')
|
||||||
|
|
||||||
|
# Check if local dependency uses path
|
||||||
|
if isinstance(dep_value, dict) and 'path' in dep_value:
|
||||||
|
# This is a local dep with path, which is correct
|
||||||
|
pass
|
||||||
|
elif workspace.crates.find_by_name(dep_name):
|
||||||
|
# Local crate exists but no path specified
|
||||||
|
errors.append(f'🚫 Workspace must use path to link local dependency {dep_name}')
|
||||||
|
|
||||||
# And the dependencies of each crate:
|
# And the dependencies of each crate:
|
||||||
for crate in workspace.crates:
|
for crate in workspace.crates:
|
||||||
for dep in crate.dependencies:
|
try:
|
||||||
check_dep(dep, crate.name)
|
for dep in crate.dependencies:
|
||||||
|
check_dep(dep, crate.name)
|
||||||
|
except ValueError as e:
|
||||||
|
# cargo-workspace library has a bug with path+version combinations
|
||||||
|
# Parse TOML directly for this crate
|
||||||
|
crate_toml_path = os.path.join(crate.path, 'Cargo.toml')
|
||||||
|
if os.path.exists(crate_toml_path):
|
||||||
|
with open(crate_toml_path, 'r') as f:
|
||||||
|
crate_toml = toml.load(f)
|
||||||
|
for section in ['dependencies', 'dev-dependencies', 'build-dependencies']:
|
||||||
|
deps = crate_toml.get(section, {})
|
||||||
|
for dep_name, dep_value in deps.items():
|
||||||
|
if isinstance(dep_value, dict) and 'git' in dep_value:
|
||||||
|
if crate.name not in ALLOWED_GIT_DEPS.get(dep_name, []):
|
||||||
|
errors.append(f'🚫 Found git dependency {dep_name} in {crate.name}')
|
||||||
|
|
||||||
if errors:
|
if errors:
|
||||||
print('❌ Found errors:')
|
print('❌ Found errors:')
|
||||||
|
|||||||
@@ -134,8 +134,6 @@ Terminoloji kılavuzu için `.claude/TERMINOLOGY.md` dosyasına bak.
|
|||||||
|
|
||||||
*Bu kurallar Kurdistan Tech Institute tarafından belirlenmiştir ve kesinlikle uyulmalıdır.*
|
*Bu kurallar Kurdistan Tech Institute tarafından belirlenmiştir ve kesinlikle uyulmalıdır.*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
*eskiden kalan ve baska bir dosyaya yazdigin kurallar
|
*eskiden kalan ve baska bir dosyaya yazdigin kurallar
|
||||||
# Claude Code Kuralları - Pezkuwi SDK
|
# Claude Code Kuralları - Pezkuwi SDK
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user