Repository: conan-io/conan

Issue:
[scm] deducing `url` with a windows path
It looks like when `auto` is deduced for `url`, it has to be properly escaped for '\\', just in case if it happens to be a local (windows) path instead of a proper git url.

I have scm section in my conanfile.py like the following
```
    scm = {
        'type': 'git',
        'url': 'auto',
        'revision': 'auto'
    }
```
I am getting the following error from our bamboo builds

```
[package]: Repo origin deduced by 'auto': file://C:\bamboo\xml-data\build-dir\_git-repositories-cache\3da5a99bbc924e3c4d1788734921ce3e6554ac8c
[snip]
[package]: A new conanfile.py version was exported
ERROR: Unable to load conanfile in [snip]\export\conanfile.py
File "<frozen importlib._bootstrap>", line 684, in _load
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 674, in exec_module
File "<frozen importlib._bootstrap_external>", line 781, in get_code
File "<frozen importlib._bootstrap_external>", line 741, in source_to_code
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "[snip]\export\conanfile.py", line 16
scm = {"url": "file://C:\bamboo\xml-data\build-dir\_git-repositories-cache\3da5a99bbc924e3c4d1788734921ce3e6554ac8c",
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 16-17: truncated \xXX escape
```

As it turns out, due to local bamboo git repo caching,  I shouldn't use `auto` for `url` but conan should not fail due to windows paths in a deduced `url`.

Of course if it didn't fail, I wouldn't have noticed this *issue* this easily, perhaps conan should give a warning or fail with a more descriptive message if the deduced `url` ends up being a local path instead of a proper git url.





Discussion:

Resolving patch:
diff --git a/conans/client/cmd/export.py b/conans/client/cmd/export.py
--- a/conans/client/cmd/export.py
+++ b/conans/client/cmd/export.py
@@ -113,6 +113,9 @@ def _capture_export_scm_data(conanfile, src_path, destination_folder, output, pa
         origin = scm.get_remote_url()
         if not origin:
             raise ConanException("Repo origin cannot be deduced by 'auto'")
+        if os.path.exists(origin):
+            output.warn("Repo origin looks like a local path: %s" % origin)
+            origin = origin.replace("\\", "/")
         output.success("Repo origin deduced by 'auto': %s" % origin)
         scm.url = origin
     if scm.revision == "auto":


Test patch:
diff --git a/conans/test/functional/scm_test.py b/conans/test/functional/scm_test.py
--- a/conans/test/functional/scm_test.py
+++ b/conans/test/functional/scm_test.py
@@ -79,6 +79,23 @@ class ConanLib(ConanFile):
         folder = self.client.client_cache.source(ConanFileReference.loads("lib/0.1@user/channel"))
         self.assertIn("othersubfolder", os.listdir(folder))
 
+    def test_auto_filesystem_remote_git(self):
+        # https://github.com/conan-io/conan/issues/3109
+        conanfile = base.format(directory="None", url="auto", revision="auto")
+        repo = temp_folder()
+        self.client.save({"conanfile.py": conanfile, "myfile.txt": "My file is copied"}, repo)
+        self.client.runner("git init .", cwd=repo)
+        self.client.runner('git config user.email "you@example.com"', cwd=repo)
+        self.client.runner('git config user.name "Your Name"', cwd=repo)
+        self.client.runner("git add .", cwd=repo)
+        self.client.runner('git commit -m  "commiting"', cwd=repo)
+        self.client.runner('git clone "%s" .' % repo, cwd=self.client.current_folder)
+        self.client.run("export . user/channel")
+        self.assertIn("WARN: Repo origin looks like a local path", self.client.out)
+        os.remove(self.client.client_cache.scm_folder(ConanFileReference.loads("lib/0.1@user/channel")))
+        self.client.run("install lib/0.1@user/channel --build")
+        self.assertIn("lib/0.1@user/channel: Getting sources from url:", self.client.out)
+
     def test_auto_git(self):
         curdir = self.client.current_folder.replace("\\", "/")
         conanfile = base.format(directory="None", url="auto", revision="auto")