Пример #1
0
    def test_A_Breathing(self):
        with phlsys_fs.chtmpdir_context():
            fetch_config = str(
                'remote.origin.fetch=+refs/arcyd/landinglog'
                ':refs/arcyd/origin/landinglog')

            run = phlsys_subprocess.run_commands

            run('git init --bare origin')
            run('git clone origin dev --config ' + fetch_config)

            with phlsys_fs.chdir_context('dev'):

                # make an initial commit on the master branch
                run('touch README')
                run('git add README')
                run('git commit README -m initial_commit')
                run('git push origin master')
                run('git checkout -b myfeature')

                # create a new branch with unique content
                with open('README', 'w') as f:
                    f.write('myfeature content')
                run('git add README')
                run('git commit README -m myfeature_content')
                run('git push -u origin myfeature')

            dev = phlsys_git.Repo('dev')

            # make sure we can prepend a branch to the landinglog when empty
            abdt_landinglog.prepend(dev, '1234', 'myfeature', '4567')
            log = abdt_landinglog.get_log(dev)
            self.assertEqual(1, len(log))
            self.assertEqual(log[0].review_sha1, "1234")
            self.assertEqual(log[0].name, "myfeature")
            self.assertEqual(log[0].landed_sha1, "4567")

            # make sure we can prepend another branch
            abdt_landinglog.prepend(dev, '5678', 'newfeature', '8901')
            log = abdt_landinglog.get_log(dev)
            self.assertEqual(2, len(log))
            self.assertEqual(log[0].review_sha1, "5678")
            self.assertEqual(log[0].name, "newfeature")
            self.assertEqual(log[0].landed_sha1, "8901")
            self.assertEqual(log[1].review_sha1, "1234")
            self.assertEqual(log[1].name, "myfeature")
            self.assertEqual(log[1].landed_sha1, "4567")

            # make a new, independent clone and make sure we get the same log
            abdt_landinglog.push_log(dev, 'origin')
            run('git clone origin dev2 --config ' + fetch_config)
            with phlsys_fs.chdir_context('dev2'):
                run('git fetch')
            dev2 = phlsys_git.Repo('dev2')
            self.assertListEqual(
                abdt_landinglog.get_log(dev),
                abdt_landinglog.get_log(dev2))
Пример #2
0
    def test_A_Breathing(self):
        with phlsys_fs.chtmpdir_context():
            fetch_config = str('remote.origin.fetch=+refs/arcyd/landinglog'
                               ':refs/arcyd/origin/landinglog')

            run = phlsys_subprocess.run_commands

            run('git init --bare origin')
            run('git clone origin dev --config ' + fetch_config)

            with phlsys_fs.chdir_context('dev'):

                # make an initial commit on the master branch
                run('touch README')
                run('git add README')
                run('git commit README -m initial_commit')
                run('git push origin master')
                run('git checkout -b myfeature')

                # create a new branch with unique content
                with open('README', 'w') as f:
                    f.write('myfeature content')
                run('git add README')
                run('git commit README -m myfeature_content')
                run('git push -u origin myfeature')

            dev = phlsys_git.Repo('dev')

            # make sure we can prepend a branch to the landinglog when empty
            abdt_landinglog.prepend(dev, '1234', 'myfeature', '4567')
            log = abdt_landinglog.get_log(dev)
            self.assertEqual(1, len(log))
            self.assertEqual(log[0].review_sha1, "1234")
            self.assertEqual(log[0].name, "myfeature")
            self.assertEqual(log[0].landed_sha1, "4567")

            # make sure we can prepend another branch
            abdt_landinglog.prepend(dev, '5678', 'newfeature', '8901')
            log = abdt_landinglog.get_log(dev)
            self.assertEqual(2, len(log))
            self.assertEqual(log[0].review_sha1, "5678")
            self.assertEqual(log[0].name, "newfeature")
            self.assertEqual(log[0].landed_sha1, "8901")
            self.assertEqual(log[1].review_sha1, "1234")
            self.assertEqual(log[1].name, "myfeature")
            self.assertEqual(log[1].landed_sha1, "4567")

            # make a new, independent clone and make sure we get the same log
            abdt_landinglog.push_log(dev, 'origin')
            run('git clone origin dev2 --config ' + fetch_config)
            with phlsys_fs.chdir_context('dev2'):
                run('git fetch')
            dev2 = phlsys_git.Repo('dev2')
            self.assertListEqual(abdt_landinglog.get_log(dev),
                                 abdt_landinglog.get_log(dev2))
    def land(self, author_name, author_email, message):
        """Integrate the branch into the base and remove the review branch."""

        review_hash = phlgit_revparse.get_sha1(self._clone, self._tracking_branch.remote_branch)

        self._clone.checkout_forced_new_branch(self._tracking_branch.base, self._tracking_branch.remote_base)

        try:
            result = self._lander(self._clone, self._tracking_branch.remote_branch, author_name, author_email, message)
        except abdt_lander.LanderException as e:
            self._clone.call("reset", "--hard")  # fix the working copy
            raise abdt_exception.LandingException(str(e), self.review_branch_name(), self._tracking_branch.base)

        landing_hash = phlgit_revparse.get_sha1(self._clone, self._tracking_branch.base)

        # don't tryloop here as it's more expected that we can't push the base
        # due to permissioning or some other error
        try:
            self._clone.push(self._tracking_branch.base)
        except Exception as e:
            raise abdt_exception.LandingPushBaseException(str(e), self.review_branch_name(), self._tracking_branch.base)

        self._tryloop(
            lambda: self._clone.push_delete(self._tracking_branch.branch, self.review_branch_name()),
            "push-delete-landed",
        )

        abdt_landinglog.prepend(self._clone, review_hash, self.review_branch_name(), landing_hash)

        # push the landing log, don't care if it fails to push
        try:

            def push_landinglog():
                abdt_landinglog.push_log(self._clone, self._clone.get_remote())

            self._tryloop(push_landinglog, "push-landinglog")
        except Exception:
            # XXX: don't worry if we can't push the landinglog, this is most
            #      likely a permissioning issue but not a showstopper.
            #      we should probably nag on the review instead.
            pass

        self._review_branch = None
        self._tracking_branch = None

        return result