|
| 1 | +# -*- coding: UTF-8 -*- |
| 2 | +# |
| 3 | +# Copyright 2010-2014 The pygit2 contributors |
| 4 | +# |
| 5 | +# This file is free software; you can redistribute it and/or modify |
| 6 | +# it under the terms of the GNU General Public License, version 2, |
| 7 | +# as published by the Free Software Foundation. |
| 8 | +# |
| 9 | +# In addition to the permissions in the GNU General Public License, |
| 10 | +# the authors give you unlimited permission to link the compiled |
| 11 | +# version of this file into combinations with other programs, |
| 12 | +# and to distribute those combinations without any restriction |
| 13 | +# coming from the use of this file. (The General Public License |
| 14 | +# restrictions do apply in other respects; for example, they cover |
| 15 | +# modification of the file, and distribution when not linked into |
| 16 | +# a combined executable.) |
| 17 | +# |
| 18 | +# This file is distributed in the hope that it will be useful, but |
| 19 | +# WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 21 | +# General Public License for more details. |
| 22 | +# |
| 23 | +# You should have received a copy of the GNU General Public License |
| 24 | +# along with this program; see the file COPYING. If not, write to |
| 25 | +# the Free Software Foundation, 51 Franklin Street, Fifth Floor, |
| 26 | +# Boston, MA 02110-1301, USA. |
| 27 | + |
| 28 | +# Import from the future |
| 29 | +from __future__ import absolute_import |
| 30 | +from __future__ import unicode_literals, print_function |
| 31 | + |
| 32 | +# Import from the Standard Library |
| 33 | +import binascii |
| 34 | +import unittest |
| 35 | +import tempfile |
| 36 | +import os |
| 37 | +from os.path import join, realpath |
| 38 | +import sys |
| 39 | + |
| 40 | +# Import from pygit2 |
| 41 | +from pygit2 import GIT_OBJ_ANY, GIT_OBJ_BLOB, GIT_OBJ_COMMIT |
| 42 | +from pygit2 import init_repository, clone_repository, discover_repository |
| 43 | +from pygit2 import Oid, Reference, hashfile |
| 44 | +import pygit2 |
| 45 | +from . import utils |
| 46 | + |
| 47 | +try: |
| 48 | + import __pypy__ |
| 49 | +except ImportError: |
| 50 | + __pypy__ = None |
| 51 | + |
| 52 | +class RepositorySignatureTest(utils.RepoTestCase): |
| 53 | + |
| 54 | + def test_no_attr(self): |
| 55 | + self.assertIsNone(self.repo.get_attr('file', 'foo')) |
| 56 | + |
| 57 | + with open(join(self.repo.workdir, '.gitattributes'), 'w+') as f: |
| 58 | + print('*.py text\n', file=f) |
| 59 | + print('*.jpg -text\n', file=f) |
| 60 | + print('*.sh eol=lf\n', file=f) |
| 61 | + |
| 62 | + self.assertIsNone(self.repo.get_attr('file.py', 'foo')) |
| 63 | + self.assertTrue(self.repo.get_attr('file.py', 'text')) |
| 64 | + self.assertFalse(self.repo.get_attr('file.jpg', 'text')) |
| 65 | + self.assertEqual("lf", self.repo.get_attr('file.sh', 'eol')) |
0 commit comments