aboutsummaryrefslogtreecommitdiff
path: root/tests/28_test_gbp_git_repository_commit_dir.py
blob: 67d4750056ec212b190f5f0df869a629e16b8e78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# vim: set fileencoding=utf-8 :

import os

from . testutils import DebianGitTestRepo
from gbp.git.repository import GitRepositoryError


class TestGitRepositoryCommitDir(DebianGitTestRepo):
    def setUp(self):
        DebianGitTestRepo.setUp(self)
        self.content = os.path.join(str(self.tmpdir), 'new')
        os.mkdir(self.content)
        with open(os.path.join(self.content, 'file1'), 'w') as f:
            f.write('content1')

    def test_simple(self):
        self.repo.commit_dir(self.content,
                             'new content',
                             'master',
                             create_missing_branch=True)
        self.assertEquals(self.repo.show('master:file1'), 'content1')

    def test_long_reflog(self):
        """Make sure we fail on onverly long msg resulting in an
        overly long reflog enry"""
        with self.assertRaises(GitRepositoryError):
            self.repo.commit_dir(self.content,
                                 'foo' * 100000,
                                 'master',
                                 create_missing_branch=True)

    def test_long_msg_854333(self):
        """Make sure we shorten the reflog entry properly"""
        self.repo.commit_dir(self.content,
                             'foo\n' * 100000,
                             'master',
                             create_missing_branch=True)
        self.assertEquals(self.repo.show('master:file1'), 'content1')
        out, dummy, ret = self.repo._git_inout('reflog', [])
        self.assertEquals(ret, 0)
        self.assertIn('HEAD@{0}: gbp: foo\n', out)