Repository: conda/conda-build

Issue:
Don't filter git metafiles out when building
I am including a cookiecutter template for creating well-formed python projects with an (internal) utility package. This template includes all I need for good version control, i.e. a pre-filled `.gitignore` and `.gitattributes` file.
Building the package with `python setup.py sdist` works nicely. 
Building the package with `python setup.py bdist` works as well, except for an [unrelated issue](https://github.com/audreyr/cookiecutter/issues/1049) with compiled template files, which I since circumvented. 


### Actual Behavior

Building the package with `python setup.py bdist_conda` nearly works, but my shipped template is missing the `.gitignore`, but not the `.gitattributes` files!

### Expected Behavior

Building the package with `python setup.py bdist_conda` works, and my package contains all the files I want it to.

I am pretty sure I have tracked down the culprit commit to [this](https://github.com/conda/conda-build/commit/cf95ad80ded68597b2e01dbae9b7ff1c7439a13e#diff-c4cfa32f287679b20f86b99df93b3188) (cf. #1585) where a filter was adapted to filter out some files from the list of files to be copied. I can understand that you filter out the `.git` directory (at least I have not yet had a usecase for that), but *please* don't filter out `.gitignore`. I also think that `.gitmodules` should stay.
Indeed, the relevant [test](https://github.com/conda/conda-build/blob/cf95ad80ded68597b2e01dbae9b7ff1c7439a13e/tests/test_utils.py#L174) only tests for the removal of the `.git`directory.

Note: The files have explicitly been included by a MANIFEST.in with a `recursive-include mypgk/project_template *` entry. If you want to generally remove all `.gitignore` files, maybe this can be used to ensure that *explicitly whitelisted* files still make it into the package.

### Steps to Reproduce

* Create a python package
* Include a `.gitignore` file because you want to ship a nice git repo template
* Observe that the `.gitignore` file is gone in the final package in conda-bld

##### `Output of conda info`
```
 conda info

     active environment : None
       user config file : C:\Users\buchner\.condarc
 populated config files : C:\Users\buchner\.condarc
          conda version : 4.5.0
    conda-build version : 3.7.1
         python version : 3.6.4.final.0
       base environment : C:\Continuum\anaconda3  (writable)
           channel URLs : <snip>
                          <snip>
                          https://repo.anaconda.com/pkgs/main/win-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/free/win-64
                          https://repo.anaconda.com/pkgs/free/noarch
                          https://repo.anaconda.com/pkgs/r/win-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/pro/win-64
                          https://repo.anaconda.com/pkgs/pro/noarch
                          https://repo.anaconda.com/pkgs/msys2/win-64
                          https://repo.anaconda.com/pkgs/msys2/noarch
                          https://conda.anaconda.org/conda-forge/win-64
                          https://conda.anaconda.org/conda-forge/noarch
          package cache : C:\Continuum\anaconda3\pkgs
                          C:\Users\buchner\AppData\Local\conda\conda\pkgs
       envs directories : C:\Continuum\anaconda3\envs
                          C:\Users\buchner\AppData\Local\conda\conda\envs
                          C:\Users\buchner\.conda\envs
               platform : win-64
             user-agent : conda/4.5.0 requests/2.18.4 CPython/3.6.4 Windows/10 Windows/10.0.16299
          administrator : False
             netrc file : None
           offline mode : False
```




Discussion:
This seems reasonable to me.  Do you mind submitting a PR to make this change?  It would go in https://github.com/conda/conda-build/blob/master/conda_build/utils.py#L1220-L1225 - looks like you may just need to remove some lines.
sure. :-)

Resolving patch:
diff --git a/conda_build/utils.py b/conda_build/utils.py
--- a/conda_build/utils.py
+++ b/conda_build/utils.py
@@ -1220,10 +1220,8 @@ def apply_pin_expressions(version, min_pin='x.x.x.x.x.x.x', max_pin='x'):
 def filter_files(files_list, prefix, filter_patterns=('(.*[\\\\/])?\.git[\\\\/].*',
                                                       '(.*[\\\\/])?\.git$',
                                                       '(.*)?\.DS_Store.*',
-                                                      '(.*)?\.gitignore',
-                                                      'conda-meta.*',
-                                                      '(.*)?\.gitmodules')):
-    """Remove things like .git from the list of files to be copied"""
+                                                      'conda-meta.*')):
+    """Remove things like the .git directory from the list of files to be copied"""
     for pattern in filter_patterns:
         r = re.compile(pattern)
         files_list = set(files_list) - set(filter(r.match, files_list))


Test patch:
diff --git a/tests/test_utils.py b/tests/test_utils.py
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -217,7 +217,8 @@ def test_filter_files():
     # Example of valid 'x.git' directory:
     #    lib/python3.4/site-packages/craftr/stl/craftr.utils.git/Craftrfile
     files_list = ['a', 'x.git/a', 'something/x.git/a',
-                  'x.git\\a', 'something\\x.git\\a']
+                  'x.git\\a', 'something\\x.git\\a', 'something/.gitmodules',
+                  'some/template/directory/.gitignore']
     assert len(utils.filter_files(files_list, '')) == len(files_list)