Repository: conan-io/conan

Issue:
[bug] conan config install skips files if ".git" is in the path
I had set my `CONAN_USER_HOME` env-var to "$HOME/.gitlab-conan" (doesn't matter why).  
Later, I ran the `conan config install` command, providing a git repo that stores shared-company config, but that command has appeared to silently fail, or do nothing at all, as the config hasn't been applied, at all.  
The configuration repo is properly configured as I've tested it on other environments where conan's home is set to the default path, `~/.conan`, and it works as expected.  

When I run the command, I always get the output `Repo cloned!` and that's it, it quits right after. So I've decided to dig in and find out why, and I found that inside the [conans/client/conf/config_installer.py file](https://github.com/conan-io/conan/blob/03b3d71890c537df1154b3d04cc35ed2654a5894/conans/client/conf/config_installer.py), on [this line](https://github.com/conan-io/conan/blob/03b3d71890c537df1154b3d04cc35ed2654a5894/conans/client/conf/config_installer.py#L133), there's a check for the `.git` word being in the `root` string returned from `walk()`. I get the idea here, but it might be required to re-implement this to look for `.git` only in the last component of the `root`, as this is what actually matters, allowing other components of the path to anything the user desires.  
It might not be that trivial to solve this nicely, so an alternative could be to warn users in the docs about setting conan home to paths that include `.git` in it.

### Environment Details (include every applicable attribute)
  * Operating System+version: Ubuntu 16.04 (Docker container)
  * Conan version: 1.34.0
  * Python version: 3.8.8

### Steps to reproduce (Include if Applicable)
1. Set the conan home to a path that has `.git` in it, no matter where exactly, e.g. `.gitlab`
2. Try to install some config using `conan config install`



Discussion:
Hi @MrPointer,

I tried to reproduce your issue but it working fine for me. I set CONAN_USER_HOME to a local cloned repo (with `.git` folder inside it). Then I did a conan config install from a github repo. Conan copied the contents of the github repo to `$CONAN_USER_HOME/.conan` folder as expected.

As you pointed out, the `.git` folder from the github repo is skipped, as you only need the contents of the repo and not to create a repo itself in the config folder. There are other files skipped on purpose such as *license.txt* or *readme.md* files.

If you could provide me with a github repo to `conan config install` I would be willing to try to reproduce it further. Thanks a lot.
You probably misunderstood me, or the exact scenario I'm describing. I'll try to be more specific 😅  

Let's assume I have the following path set as `CONAN_USER_HOME`: `~/.gitlab-conan`  
It means that conan would create a `.conan` subdir under this path, resulting in `~/.gitlab-conan/.conan`, under which all the configuration resides.  
If you'll try to `conan config install` in this scenario, you won't be able to, because the code that processes directories will skip all of the directories found in the config-repo, as the `.git` string would be part of the `root` string variable all the time. Why? Because `.gitlab-conan` contains the substr `.git`, and AFAIK, Python will match against it when checking if this substr is in a string.  

I'm talking about this piece of code:
```python
for root, dirs, files in walk(folder):
        dirs[:] = [d for d in dirs if d != ".git"]
        if ".git" in root:
            continue
```

I hope it makes it a bit clearer 🙂 
Thanks for the clarification. Do you mean you are installing from that `~/.gitlab-conan` folder as well? I mean, doing something like `conan config install ~/.gitlab-conan/.conan`?
No, this is only where I'm installing to. I can't provide the exact git repo that stores my config because it's proprietary, but the full command looks something like this: `conan config install <url-to-git-repo> --type git`

Resolving patch:
diff --git a/conans/client/conf/config_installer.py b/conans/client/conf/config_installer.py
--- a/conans/client/conf/config_installer.py
+++ b/conans/client/conf/config_installer.py
@@ -130,8 +130,6 @@ 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:
-            continue
         for f in files:
             _process_file(root, f, config, cache, output, folder)
 


Test patch:
diff --git a/conans/test/functional/command/config_install_test.py b/conans/test/functional/command/config_install_test.py
--- a/conans/test/functional/command/config_install_test.py
+++ b/conans/test/functional/command/config_install_test.py
@@ -752,3 +752,23 @@ 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):
+        # https://github.com/conan-io/conan/issues/8594
+        folder = os.path.join(temp_folder(), ".gitlab-conan", ".conan")
+        client = TestClient(cache_folder=folder)
+        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"')
+        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
+        client.run('config install "%s/.git" --type git' % self.folder)
+        conf = load(client.cache.conan_conf_path)
+        assert "config_install_interval = 5m" in conf
+        dirs = os.listdir(client.cache.cache_folder)
+        assert ".git" not in dirs