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

auto create default global.conf #13746

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion conans/client/cache/cache.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import platform
import textwrap
from typing import List

import yaml
Expand Down Expand Up @@ -167,8 +168,16 @@ def new_config(self):
content = template.render({"platform": platform, "os": os, "distro": distro,
"conan_version": conan_version,
"conan_home_folder": self.cache_folder})

self._new_config.loads(content)
else: # creation of a blank global.conf file for user convenience
default_global_conf = textwrap.dedent("""\
# Core configuration (type 'conan config list' to list possible values)
# e.g, for CI systems, to raise if user input would block
# core:non_interactive = True
# some tools.xxx config also possible, though generally better in profiles
# tools.android:ndk_path = my/path/to/android/ndk
""")
save(self.new_config_path, default_global_conf)
return self._new_config

@property
Expand Down
9 changes: 8 additions & 1 deletion conans/test/integration/configuration/conf/test_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from conan import conan_version
from conans.errors import ConanException
from conans.util.files import save
from conans.util.files import save, load
from conans.test.utils.tools import TestClient


Expand Down Expand Up @@ -270,3 +270,10 @@ def test_nonexisting_conf_global_conf():
c.save({"conanfile.txt": ""})
c.run("install . ", assert_error=True)
assert "ERROR: Unknown conf 'tools.unknown:conf'" in c.out


def test_global_conf_auto_created():
c = TestClient()
c.run("config list") # all commands will trigger
global_conf = load(c.cache.new_config_path)
assert "# core:non_interactive = True" in global_conf