def submit(self):
        """
        Run a build to create the image for the repository.

        Progress of the build can be monitored by listening for items in
        the Queue passed to the constructor as `q`.
        """

        def break_callback():
            return self.stop_event.is_set()

        env = os.environ.copy()
        if self.git_credentials:
            env["GIT_CREDENTIAL_ENV"] = self.git_credentials

        cmd = self.get_cmd()
        app_log.info("Starting build: %s", " ".join(cmd))

        try:
            self.progress(
                ProgressEvent.Kind.BUILD_STATUS_CHANGE,
                ProgressEvent.BuildStatus.RUNNING,
            )
            for line in _execute_cmd(
                cmd, capture=True, break_callback=break_callback, env=env
            ):
                self._handle_log(line)
            self.progress(
                ProgressEvent.Kind.BUILD_STATUS_CHANGE,
                ProgressEvent.BuildStatus.BUILT,
            )
        except subprocess.CalledProcessError:
            self.progress(
                ProgressEvent.Kind.BUILD_STATUS_CHANGE, ProgressEvent.BuildStatus.FAILED
            )
        except Exception:
            app_log.exception("Error in watch stream for %s", self.name)
            raise

        Run a build to create the image for the repository.

        Progress of the build can be monitored by listening for items in
        the Queue passed to the constructor as `q`.
        
binderhub/build_local.py