Ejemplo n.º 1
0
 def test0302_commit_name(self):
     local = os.path.join(LOCAL_DIRS, 'local')
     test_file = os.path.join(local, 'test')
     open(test_file, 'w+').close()
     gitcmd.add(test_file)
     gitcmd.commit(test_file, 'test', name="Its Me", mail="*****@*****.**")
     cwd = os.getcwd()
     os.chdir(local)
     _, out, _ = command("git log")
     os.chdir(cwd)
     self.assertIn("Its Me <*****@*****.**>", out)
Ejemplo n.º 2
0
    def test0501_push_no_url(self):
        local = os.path.join(LOCAL_DIRS, 'local')
        test_file = os.path.join(local, 'test')

        gitcmd.clone(LOCAL_DIRS, HOST_DIR, to='local')
        open(test_file, 'w+').close()
        gitcmd.add(test_file)
        gitcmd.commit(test_file, 'test')
        ret, out, err = gitcmd.push(local)

        self.assertEqual(ret, 0)
        self.assertIn("master -> master", err)
Ejemplo n.º 3
0
    def test1500_show_last_revision(self):
        local = os.path.join(LOCAL_DIRS, 'local')
        test_file = os.path.join(local, 'test')

        open(test_file, 'w+').close()
        gitcmd.add(test_file)
        gitcmd.commit(test_file, 'test')
        with open(test_file, 'w+') as f:
            print("Test string", file=f)

        ret, out, err = gitcmd.show_last_revision(test_file)
        self.assertEqual(ret, 0)
        self.assertIn('test', out)
Ejemplo n.º 4
0
    def test0600_branch(self):
        local = os.path.join(LOCAL_DIRS, 'local')
        test_file = os.path.join(local, 'test')

        gitcmd.clone(LOCAL_DIRS, HOST_DIR, to='local')
        open(test_file, 'w+').close()
        gitcmd.add(test_file)
        gitcmd.commit(test_file, 'test')
        gitcmd.push(local, HOST_DIR)

        ret, out, err = gitcmd.branch(local)
        self.assertEqual(ret, 0)
        self.assertEqual(out, "* master\n")
Ejemplo n.º 5
0
    def test0403_status_to_commit(self):
        local = os.path.join(LOCAL_DIRS, 'local')
        test_file = os.path.join(local, 'test')

        gitcmd.clone(LOCAL_DIRS, HOST_DIR, to='local')
        open(test_file, 'w+').close()
        gitcmd.add(test_file)
        gitcmd.commit(test_file, 'test')
        ret, out, err = gitcmd.status(local)

        self.assertEqual(ret, 0)
        self.assertTrue(
            'Your branch is ahead of \'origin/master\' by 1 commit.' in out)
Ejemplo n.º 6
0
    def test1005_pull_exception(self):
        with self.assertRaises(gitcmd.NotInRepositoryError):
            gitcmd.pull('/tmp', 'url')

        local = os.path.join(LOCAL_DIRS, 'local')
        test_file = os.path.join(local, 'testfile')
        test_file2 = os.path.join(local, 'testfile')

        gitcmd.clone(LOCAL_DIRS, HOST_DIR, to='local')
        gitcmd.clone(LOCAL_DIRS, HOST_DIR, to='local2')
        open(test_file, 'w+').close()
        gitcmd.add(test_file)
        gitcmd.commit(test_file, 'test')
        gitcmd.push(local, HOST_DIR)
        with self.assertRaises(ValueError):
            gitcmd.pull(test_file2, HOST_DIR, "username")
Ejemplo n.º 7
0
    def test1001_pull_no_url(self):
        local = os.path.join(LOCAL_DIRS, 'local')
        local2 = os.path.join(LOCAL_DIRS, 'local2')
        test_file = os.path.join(local, 'testfile')
        test_file2 = os.path.join(local, 'testfile')

        gitcmd.clone(LOCAL_DIRS, HOST_DIR, to='local')
        gitcmd.clone(LOCAL_DIRS, HOST_DIR, to='local2')
        open(test_file, 'w+').close()
        gitcmd.add(test_file)
        gitcmd.commit(test_file, 'test')
        gitcmd.push(local, HOST_DIR)
        ret, out, err = gitcmd.pull(local2)
        self.assertEqual(ret, 0)
        self.assertIn("Fast-forward\n testfile", out)
        self.assertTrue(os.path.isfile(test_file2))
Ejemplo n.º 8
0
    def test0300_commit(self):
        local = os.path.join(LOCAL_DIRS, 'local')
        test_file = os.path.join(local, 'test')
        test_file2 = os.path.join(local, 'test2')

        open(test_file, 'w+').close()
        gitcmd.add(test_file)
        ret, out, err = gitcmd.commit(test_file, 'test')
        self.assertEqual(ret, 0)
        self.assertTrue(
            "test\n 1 file changed, 0 insertions(+), 0 deletions(-)\n create mode 100644 test"
            in out)

        open(test_file2, 'w+').close()
        gitcmd.add(test_file2)
        ret, out, err = gitcmd.commit(local, 'test')
        self.assertEqual(ret, 0)
        self.assertTrue(
            "test\n 1 file changed, 0 insertions(+), 0 deletions(-)\n create mode 100644 test2"
            in out)
Ejemplo n.º 9
0
    def test0403_status_committed(self):
        local = os.path.join(LOCAL_DIRS, 'local')
        test_file = os.path.join(local, 'test')
        test_file2 = os.path.join(local, 'test2')

        gitcmd.clone(LOCAL_DIRS, HOST_DIR, to='local')
        open(test_file, 'w+').close()
        gitcmd.add(test_file)
        gitcmd.commit(test_file, 'test')
        ret, out, err = gitcmd.status(local)
        self.assertEqual(ret, 0)
        self.assertIn("Your branch is ahead of 'origin/master' by 1 commit.",
                      out)

        open(test_file2, 'w+').close()
        gitcmd.add(test_file2)
        gitcmd.commit(test_file2, 'test')
        ret, out, err = gitcmd.status(test_file2)
        self.assertEqual(ret, 0)
        self.assertIn("Your branch is ahead of 'origin/master' by 2 commits.",
                      out)
Ejemplo n.º 10
0
 def test0301_commit_exception(self):
     with self.assertRaises(gitcmd.NotInRepositoryError):
         gitcmd.commit('/tmp', 'log')
Ejemplo n.º 11
0
 def test0302_commit_mail_noname(self):
     local = os.path.join(LOCAL_DIRS, 'local')
     test_file = os.path.join(local, 'test')
     open(test_file, 'w+').close()
     with self.assertRaises(ValueError):
         gitcmd.commit(test_file, 'test', mail="*****@*****.**")
Ejemplo n.º 12
0
 def test0302_commit_name_nomail(self):
     local = os.path.join(LOCAL_DIRS, 'local')
     test_file = os.path.join(local, 'test')
     open(test_file, 'w+').close()
     with self.assertRaises(ValueError):
         gitcmd.commit(test_file, 'test', name="Its Me")