File: 28_test_gbp_git_repository_commit_dir.py

package info (click to toggle)
git-buildpackage 0.9.39
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,464 kB
  • sloc: python: 18,427; xml: 8,746; sh: 731; makefile: 139
file content (42 lines) | stat: -rw-r--r-- 1,606 bytes parent folder | download | duplicates (2)
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.assertEqual(self.repo.show('master:file1'), b'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.assertEqual(self.repo.show('master:file1'), b'content1')
        out, dummy, ret = self.repo._git_inout('reflog', [])
        self.assertEqual(ret, 0)
        self.assertIn(b'HEAD@{0}: gbp: foo\n', out)