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

[wip] Fix config install not working when .git* folder is in the path #8605

Merged
merged 8 commits into from Mar 17, 2021
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion conans/client/conf/config_installer.py
Expand Up @@ -130,7 +130,7 @@ def _process_folder(config, folder, cache, output):
folder = os.path.join(folder, config.source_folder)
for root, dirs, files in walk(folder):
dirs[:] = [d for d in dirs if d != ".git"]
if ".git" in root:
if os.path.join(".git", "") in root:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this will make a difference in the end, the line above: dirs[:] = [d for d in dirs if d != ".git"]
Is already filtering the .git folder.
Also, the new comparison will compare if .git/ is in root that will have the value my/root/path/git so it will always be false because of the forward slash join is going to add in the end.
I don't know if I'm missing something, but is this comparison needed in the end?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right, I have removed that line as it looks useless and added a check in the test

continue
for f in files:
_process_file(root, f, config, cache, output, folder)
Expand Down
17 changes: 17 additions & 0 deletions conans/test/functional/command/config_install_test.py
Expand Up @@ -752,3 +752,20 @@ def test_config_install_remove_config_repo(self):
self.assertNotIn("Repo cloned!", self.client.out)
# ... and updates the next schedule
self.assertGreater(os.path.getmtime(self.client.cache.config_install_file), last_change)

def test_config_fails_git_folder(self):
folder = os.path.join(temp_folder(), ".gitlab-conan", ".conan")
client = TestClient(cache_folder=folder)
assert ".gitlab-conan" in client.cache_folder
assert os.path.basename(client.cache_folder) == ".conan"
conf = load(client.cache.conan_conf_path)
assert "config_install_interval = 5m" not in conf
with client.chdir(self.folder):
client.run_command('git init .')
client.run_command('git add .')
client.run_command('git config user.name myname')
client.run_command('git config user.email myname@mycompany.com')
client.run_command('git commit -m "mymsg"')
client.run('config install "%s/.git" --type git' % self.folder)
conf = load(client.cache.conan_conf_path)
assert "config_install_interval = 5m" in conf