static async getState()

in src/desktop/current_branch_refresher.ts [169:214]


  static async getState(
    projectInRepository: ProjectInRepository | undefined,
    userInitiated: boolean,
  ): Promise<TreeState> {
    if (!projectInRepository) return INVALID_STATE;
    const { project } = projectInRepository;
    const gitLabService = getGitLabService(projectInRepository);
    let securityFindings;
    try {
      const { type, pipeline, mr } = await CurrentBranchRefresher.getPipelineAndMrForHead(
        gitLabService,
        projectInRepository,
      );
      const jobs = await getJobs(projectInRepository, pipeline);
      const minimalIssues = mr ? await gitLabService.getMrClosingIssues(project, mr.iid) : [];
      if (mr && getLocalFeatureFlagService().isEnabled(FeatureFlag.SecurityScans)) {
        securityFindings = await getAllSecurityReports(
          gitLabService,
          projectInRepository.project,
          mr,
        );
      }

      const issues = (
        await Promise.all(
          minimalIssues
            .map(mi => mi.iid)
            .filter(notNullOrUndefined)
            .map(iid => gitLabService.getSingleProjectIssue(project, iid)),
        )
      ).filter(notNullOrUndefined);
      return {
        type,
        projectInRepository,
        pipeline,
        mr,
        jobs,
        issues,
        userInitiated,
        securityFindings,
      };
    } catch (e) {
      log.error(e);
      return { type: 'invalid', error: e };
    }
  }