示例#1
0
    def clone(self, task, project_name):
        callbacks = RemoteCallbacks(self)

        fetch_options = Ggit.FetchOptions()
        fetch_options.set_remote_callbacks(callbacks)

        clone_options = Ggit.CloneOptions()
        clone_options.set_is_bare(False)
        clone_options.set_checkout_branch("master")
        clone_options.set_fetch_options(fetch_options)

        uri = self.get_project_uri(project_name)
        self.location = self.get_project_dir(project_name)

        self.write_line("Cloning %s into %s ..." %
                        (project_name, self.location.get_path()))

        try:
            repository = Ggit.Repository.clone(uri, self.location,
                                               clone_options)
        except Exception as ex:
            self.printerr(ex.message)
            task.return_int(1)
            return

        # TODO: Find project dependencies, install
        #       that could be xdg-app runtime, jhbuild, etc
        #self.write_line("Locating project dependencies")

        # Load the project and try to build it.
        Ide.Context.new_async(self.location, task.get_cancellable(),
                              self.get_context_cb, task)