예제 #1
0
    def test_push(self):
        gitrepo1 = pygit2.Repository(self.main_repo_bare)
        gitrepo2 = pygit2.Repository(self.cloned_from_repo)
        print "Main repo %s " % gitrepo1.path
        print "Cloned from repo %s " % gitrepo2.path

        walk_topological = lambda repo: repo.walk(
            repo.head.target, pygit2.GIT_SORT_TOPOLOGICAL)

        changesets1 = list(walk_topological(gitrepo1))
        changesets2 = list(walk_topological(gitrepo2))
        self.assertNotEqual(len(changesets1), len(changesets2))

        repo2 = Repository(self.cloned_from_repo)
        with self.assertRaises(RepositoryError):
            repo2.push(
                self.main_repo_bare,
                "inexistent_destination",
                ref_name='master')

        repo2.push(self.main_repo, self.main_repo_bare, ref_name='master')

        changesets1 = list(walk_topological(gitrepo1))
        changesets2 = list(walk_topological(gitrepo2))
        self.assertEquals(len(changesets1), len(changesets2))
    def test_push_all_with_reference_and_revision(self):
        git1 = GitCmd(self.main_repo_bare)
        git2 = GitCmd(self.cloned_from_repo)

        repo2 = Repository(self.cloned_from_repo)
        repo2.commit('A commit', allow_empty=True)
        cs = repo2.commit('A second commit', allow_empty=True)
        repo2.tag('unqualified', revision=cs.hash)
        notes_ref = repo2.append_note('some note dude', cs.hash)

        repo2.push(self.main_repo,
                   self.main_repo_bare,
                   rev=cs.hash,
                   ref_name='master')

        notes_ref_repo1, commit_ref_repo1 = git1('notes', 'list').split()
        notes_ref_repo2, commit_ref_repo2 = git2('notes', 'list').split()

        self.assertEqual(commit_ref_repo1, commit_ref_repo2)
        self.assertEqual(notes_ref_repo1, notes_ref_repo2)
        self.assertEqual(notes_ref, notes_ref_repo1)

        changesets1 = list(
            git1('log', 'unqualified', '--', pretty='oneline', _iter=True))
        changesets2 = list(
            git2('log', 'unqualified', '--', pretty='oneline', _iter=True))
        self.assertEquals(changesets1, changesets2)
예제 #3
0
    def test_push_to_unqualified_destination(self):
        git1 = GitCmd(self.main_repo_bare)
        git2 = GitCmd(self.cloned_from_repo)

        repo2 = Repository(self.cloned_from_repo)
        cs = repo2.commit('A commit', allow_empty=True)

        # Pushing a revision to a reference name that doesn't exist is
        # considered a push to an unqualified destination
        repo2.push(self.main_repo, self.main_repo_bare, rev=cs.hash, ref_name='unqualified')

        changesets1 = list(git1('log', 'unqualified', pretty='oneline', _iter=True))
        changesets2 = list(git2('log', cs.hash, pretty='oneline', _iter=True))
        self.assertEquals(changesets1, changesets2)
    def test_push_to_unqualified_destination(self):
        git1 = GitCmd(self.main_repo_bare)
        git2 = GitCmd(self.cloned_from_repo)

        repo2 = Repository(self.cloned_from_repo)
        cs = repo2.commit('A commit', allow_empty=True)

        # Pushing a revision to a reference name that doesn't exist is
        # considered a push to an unqualified destination
        repo2.push(self.main_repo,
                   self.main_repo_bare,
                   rev=cs.hash,
                   ref_name='unqualified')

        changesets1 = list(
            git1('log', 'unqualified', pretty='oneline', _iter=True))
        changesets2 = list(git2('log', cs.hash, pretty='oneline', _iter=True))
        self.assertEquals(changesets1, changesets2)
예제 #5
0
    def test_push_only_notes(self):
        git1 = GitCmd(self.main_repo_bare)
        git2 = GitCmd(self.cloned_from_repo)

        repo2 = Repository(self.cloned_from_repo)
        cs = repo2.commit('A commit', allow_empty=True)

        repo2.push(self.main_repo, self.main_repo_bare, rev=cs.hash, ref_name='master')

        notes_ref = repo2.append_note('some note dude', cs.hash)
        repo2.push(self.main_repo, self.main_repo_bare, ref_name='refs/notes/*')

        notes_ref_repo1, commit_ref_repo1 = git1('notes', 'list').split()
        notes_ref_repo2, commit_ref_repo2 = git2('notes', 'list').split()

        self.assertEqual(commit_ref_repo1, commit_ref_repo2)
        self.assertEqual(notes_ref_repo1, notes_ref_repo2)
        self.assertEqual(notes_ref, notes_ref_repo1)
    def test_push(self):
        git1 = GitCmd(self.main_repo_bare)
        git2 = GitCmd(self.cloned_from_repo)

        changesets1 = list(git1('log', pretty='oneline', _iter=True))
        changesets2 = list(git2('log', pretty='oneline', _iter=True))
        self.assertNotEqual(len(changesets1), len(changesets2))

        repo2 = Repository(self.cloned_from_repo)
        with self.assertRaises(RepositoryError):
            repo2.push(self.main_repo_bare,
                       "inexistent_destination",
                       ref_name='master')

        repo2.push(self.main_repo, self.main_repo_bare, ref_name='master')

        changesets1 = list(git1('log', pretty='oneline', _iter=True))
        changesets2 = list(git2('log', pretty='oneline', _iter=True))
        self.assertEquals(len(changesets1), len(changesets2))
    def test_exterminate_branch(self):
        branch_name = 'newbranch'
        gitrepo = Repository(self.cloned_from_repo)
        gitrepo_main = Repository(self.main_repo)
        gitrepo.update(branch_name)
        # Pushing the branch to the remote repo so we can check it's removed
        # remotely too
        gitrepo.push(None, self.main_repo, ref_name=branch_name)

        self.assertEquals(len(list(gitrepo.get_branches())), 2)
        self.assertEquals(len(list(gitrepo_main.get_branches())), 4)

        gitrepo.exterminate_branch(branch_name, None, self.main_repo)

        self.assertEquals(len(list(gitrepo.get_branches())), 1)
        self.assertEquals(len(list(gitrepo_main.get_branches())), 3)

        # Terminating a branch already terminated
        # it shouldn't do anything but warning with a message
        gitrepo.exterminate_branch(branch_name, None, self.main_repo)
예제 #8
0
    def test_exterminate_branch(self):
        branch_name = 'newbranch'
        gitrepo = Repository(self.cloned_from_repo)
        gitrepo_main = Repository(self.main_repo)
        gitrepo.update(branch_name)
        # Pushing the branch to the remote repo so we can check it's removed
        # remotely too
        gitrepo.push(None, self.main_repo, ref_name=branch_name)

        self.assertEquals(len(list(gitrepo.get_branches())), 2)
        self.assertEquals(len(list(gitrepo_main.get_branches())), 2)

        gitrepo.exterminate_branch(branch_name, None, self.main_repo)

        self.assertEquals(len(list(gitrepo.get_branches())), 1)
        self.assertEquals(len(list(gitrepo_main.get_branches())), 1)

        # Terminating a branch already terminated
        # it shouldn't do anything but warning with a message
        gitrepo.exterminate_branch(branch_name, None, self.main_repo)
예제 #9
0
    def test_push(self):
        git1 = GitCmd(self.main_repo_bare)
        git2 = GitCmd(self.cloned_from_repo)

        changesets1 = list(git1('log', pretty='oneline', _iter=True))
        changesets2 = list(git2('log', pretty='oneline', _iter=True))
        self.assertNotEqual(len(changesets1), len(changesets2))

        repo2 = Repository(self.cloned_from_repo)
        with self.assertRaises(RepositoryError):
            repo2.push(
                self.main_repo_bare,
                "inexistent_destination",
                ref_name='master')

        repo2.push(self.main_repo, self.main_repo_bare, ref_name='master')

        changesets1 = list(git1('log', pretty='oneline', _iter=True))
        changesets2 = list(git2('log', pretty='oneline', _iter=True))
        self.assertEquals(len(changesets1), len(changesets2))
예제 #10
0
    def test_push_all_with_reference_and_revision(self):
        git1 = GitCmd(self.main_repo_bare)
        git2 = GitCmd(self.cloned_from_repo)

        repo2 = Repository(self.cloned_from_repo)
        repo2.commit('A commit', allow_empty=True)
        cs = repo2.commit('A second commit', allow_empty=True)
        repo2.tag('unqualified', revision=cs.hash)
        notes_ref = repo2.append_note('some note dude', cs.hash)

        repo2.push(self.main_repo, self.main_repo_bare, rev=cs.hash, ref_name='master')

        notes_ref_repo1, commit_ref_repo1 = git1('notes', 'list').split()
        notes_ref_repo2, commit_ref_repo2 = git2('notes', 'list').split()

        self.assertEqual(commit_ref_repo1, commit_ref_repo2)
        self.assertEqual(notes_ref_repo1, notes_ref_repo2)
        self.assertEqual(notes_ref, notes_ref_repo1)

        changesets1 = list(git1('log', 'unqualified', '--', pretty='oneline', _iter=True))
        changesets2 = list(git2('log', 'unqualified', '--', pretty='oneline', _iter=True))
        self.assertEquals(changesets1, changesets2)
    def test_push_only_notes(self):
        git1 = GitCmd(self.main_repo_bare)
        git2 = GitCmd(self.cloned_from_repo)

        repo2 = Repository(self.cloned_from_repo)
        cs = repo2.commit('A commit', allow_empty=True)

        repo2.push(self.main_repo,
                   self.main_repo_bare,
                   rev=cs.hash,
                   ref_name='master')

        notes_ref = repo2.append_note('some note dude', cs.hash)
        repo2.push(self.main_repo,
                   self.main_repo_bare,
                   ref_name='refs/notes/*')

        notes_ref_repo1, commit_ref_repo1 = git1('notes', 'list').split()
        notes_ref_repo2, commit_ref_repo2 = git2('notes', 'list').split()

        self.assertEqual(commit_ref_repo1, commit_ref_repo2)
        self.assertEqual(notes_ref_repo1, notes_ref_repo2)
        self.assertEqual(notes_ref, notes_ref_repo1)