Repository: conda/conda-build

Issue:
Git clone fails if port number in repo URL
Conda build seems to create an invalid directory name for caching Git repos: For our repository on `git@some.internal.server:7999`, I receive the following error message:

```
WindowsError: [Error 267] The directory name is invalid: u'c:\\home\\opt\\Miniconda2\\conda-bld\\git_cache\\git@some.internal.server:7999'
```

The full stacktrace is:

```
Traceback (most recent call last):
  File "c:\home\opt\Miniconda2\Scripts\conda-build-script.py", line 5, in <module>
    sys.exit(conda_build.cli.main_build.main())
  File "c:\home\opt\Miniconda2\lib\site-packages\conda_build\cli\main_build.py", line 234, in main
    execute(sys.argv[1:])
  File "c:\home\opt\Miniconda2\lib\site-packages\conda_build\cli\main_build.py", line 226, in execute
    already_built=None, config=config)
  File "c:\home\opt\Miniconda2\lib\site-packages\conda_build\api.py", line 81, in build
    need_source_download=need_source_download, config=config)
  File "c:\home\opt\Miniconda2\lib\site-packages\conda_build\build.py", line 942, in build_tree
    config=config)
  File "c:\home\opt\Miniconda2\lib\site-packages\conda_build\build.py", line 578, in build
    config=config)
  File "c:\home\opt\Miniconda2\lib\site-packages\conda_build\render.py", line 86, in parse_or_try_download
    source.provide(metadata.path, metadata.get_section('source'), config=config)
  File "c:\home\opt\Miniconda2\lib\site-packages\conda_build\source.py", line 498, in provide
    git = git_source(meta, recipe_dir, config=config)
  File "c:\home\opt\Miniconda2\lib\site-packages\conda_build\source.py", line 246, in git_source
    git, mirror_dir, config.work_dir, git_url, config, git_ref, git_depth, True)
  File "c:\home\opt\Miniconda2\lib\site-packages\conda_build\source.py", line 137, in git_mirror_checkout_recursive
    os.makedirs(os.path.dirname(mirror_dir))
  File "c:\home\opt\Miniconda2\lib\os.py", line 150, in makedirs
    makedirs(head, mode)
  File "c:\home\opt\Miniconda2\lib\os.py", line 157, in makedirs
    mkdir(name, mode)
WindowsError: [Error 267] The directory name is invalid: u'c:\\home\\opt\\Miniconda2\\conda-bld\\git_cache\\git@some.internal.server:7999'
An error occurred (1)
```

Running on Windows 7 with Miniconda. The output of `conda info` is:

```
Current conda install:

             platform : win-64
        conda version : 4.1.11
    conda-env version : 2.5.2
  conda-build version : 2.0.0
       python version : 2.7.11.final.0
     requests version : 2.11.1
     root environment : c:\home\opt\Miniconda2  (writable)
  default environment : c:\home\opt\Miniconda2
     envs directories : C:\home\.conda\envs
        package cache : C:\home\.conda\envs\.pkgs
         channel URLs : [DELETED]
          config file : C:\home\.condarc
         offline mode : False
    is foreign system : False
```



Discussion:
Good catch.  Seems like the colon probably needs to go.  I think @ is a valid character for paths, but I'll add a test for this just in case.


Resolving patch:
diff --git a/conda_build/source.py b/conda_build/source.py
--- a/conda_build/source.py
+++ b/conda_build/source.py
@@ -239,8 +239,7 @@ def git_source(meta, recipe_dir, config):
         git_dn = git_url.split('://')[-1].replace('/', os.sep)
         if git_dn.startswith(os.sep):
             git_dn = git_dn[1:]
-        elif git_dn[1] == ':':
-            git_dn = git_dn.replace(':', '_')
+        git_dn = git_dn.replace(':', '_')
     mirror_dir = join(config.git_cache, git_dn)
     git_mirror_checkout_recursive(
         git, mirror_dir, config.work_dir, git_url, config, git_ref, git_depth, True)


Test patch: