Ejemplo n.º 1
0
 def _test(self):
     commit_id = repo.make_commit(changed='O')
     repo.write_files(changed='X', staged='staged', untracked='untracked')
     GIT.add('staged')
     expected = [' M changed', 'A  staged', '?? untracked']
     self.assertEqual(_status(), expected)
     return commit_id
Ejemplo n.º 2
0
 def test_add(self):
     with open('1', 'w') as fp:
         fp.write('1\n')
     GIT.add('1')
     actual = GIT.infer()
     expected = [
         '[master 0ae685e] Add 1',
         ' 1 file changed, 1 insertion(+)',
         ' create mode 100644 1',
     ]
     self.assertEqual(actual, expected)
Ejemplo n.º 3
0
    def test_multiple(self):
        repo.make_commit('1')
        repo.make_commit('2')
        GIT.mv('0', '3')
        os.remove('1')

        with open('4', 'w') as fp:
            fp.write('4\n')

        with open('2', 'w') as fp:
            fp.write('6\n')
        GIT.add('2', '4')

        actual = GIT.infer('-v')
        expected = [
            '[master e80d1bc] Several changes',
            ' 3 files changed, 2 insertions(+), 1 deletion(-)',
            ' rename 0 => 3 (100%)',
            ' create mode 100644 4',
        ]
        self.assertEqual(actual, expected)
Ejemplo n.º 4
0
    def test_simple(self):
        repo.make_commit('1', '2')
        GIT.push()
        with open('3', 'w') as fp:
            fp.write('3\n')
        GIT.add('3')
        with open('4', 'w') as fp:
            fp.write('4\n')
        with open('0', 'w') as fp:
            fp.write('100\n')
        os.remove('1')

        actual = GIT.st()
        expected = [
            '\x1b[32mmaster\x1b[m...\x1b[31morigin/master\x1b[m',
            ' \x1b[31mM\x1b[m 0  | 2 \x1b[32m+\x1b[m\x1b[31m-\x1b[m',
            ' \x1b[31mD\x1b[m 1  | 1 \x1b[31m-\x1b[m',
            '\x1b[32mA\x1b[m  3  | 1 \x1b[32m+\x1b[m',
            '\x1b[31m??\x1b[m 4  ',
        ]
        self.assertEqual(actual, expected)