mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-12-12 02:45:18 +00:00
Apply repo settings: Disable loading env files as well as merging from other sources.
This commit is contained in:
parent
8d3f3bca45
commit
6bfde3beab
1 changed files with 15 additions and 1 deletions
|
|
@ -35,8 +35,22 @@ def apply_repo_settings(pr_url):
|
||||||
try:
|
try:
|
||||||
fd, repo_settings_file = tempfile.mkstemp(suffix='.toml')
|
fd, repo_settings_file = tempfile.mkstemp(suffix='.toml')
|
||||||
os.write(fd, repo_settings)
|
os.write(fd, repo_settings)
|
||||||
new_settings = Dynaconf(settings_files=[repo_settings_file])
|
|
||||||
|
try:
|
||||||
|
new_settings = Dynaconf(settings_files=[repo_settings_file],
|
||||||
|
# Disable all dynamic loading features
|
||||||
|
load_dotenv=False, # Don't load .env files
|
||||||
|
merge_enabled=False, # Don't allow merging from other sources
|
||||||
|
)
|
||||||
|
except TypeError:
|
||||||
|
# Fallback for older Dynaconf versions that don't support these parameters
|
||||||
|
new_settings = Dynaconf(settings_files=[repo_settings_file])
|
||||||
|
|
||||||
for section, contents in new_settings.as_dict().items():
|
for section, contents in new_settings.as_dict().items():
|
||||||
|
if not contents:
|
||||||
|
# Skip excluded items, such as forbidden to load env.
|
||||||
|
get_logger().debug(f"Skipping a section: {section} which is not allowed")
|
||||||
|
continue
|
||||||
section_dict = copy.deepcopy(get_settings().as_dict().get(section, {}))
|
section_dict = copy.deepcopy(get_settings().as_dict().get(section, {}))
|
||||||
for key, value in contents.items():
|
for key, value in contents.items():
|
||||||
section_dict[key] = value
|
section_dict[key] = value
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue