def checkout()

in services/ui_backend_service/plugins/plugin.py [0:0]


    def checkout(self, repository_url: str = None):
        """Fetch latest changes and checkout repository"""
        if self._repo:
            # Update repository url in case it has changed
            if repository_url:
                self._repo.remotes.set_url("origin", repository_url)

            # Fetch latest changes
            for remote in self._repo.remotes:
                remote.fetch(callbacks=self.callbacks)

            # Resolve ref and checkout
            commit, resolved_refish = self._repo.resolve_refish(self.ref if self.ref else 'origin/master')
            self._repo.checkout(resolved_refish, strategy=pygit2.GIT_CHECKOUT_FORCE)

            self.logger.info("Checkout {} at {}".format(resolved_refish.name, commit.short_id))