Skip to content
Snippets Groups Projects
Select Git revision
21 results Searching

index.ts

Blame
  • index.ts 26.38 KiB
    import is from '@sindresorhus/is';
    import JSON5 from 'json5';
    import semver from 'semver';
    import { PlatformId } from '../../../constants';
    import {
      REPOSITORY_ACCESS_FORBIDDEN,
      REPOSITORY_ARCHIVED,
      REPOSITORY_BLOCKED,
      REPOSITORY_CHANGED,
      REPOSITORY_EMPTY,
      REPOSITORY_MIRRORED,
    } from '../../../constants/error-messages';
    import { logger } from '../../../logger';
    import { BranchStatus, PrState, VulnerabilityAlert } from '../../../types';
    import * as git from '../../../util/git';
    import { setBaseUrl } from '../../../util/http/gitea';
    import { sanitize } from '../../../util/sanitize';
    import { ensureTrailingSlash } from '../../../util/url';
    import { getPrBodyStruct, hashBody } from '../pr-body';
    import type {
      BranchStatusConfig,
      CreatePRConfig,
      EnsureCommentConfig,
      EnsureCommentRemovalConfig,
      EnsureIssueConfig,
      FindPRConfig,
      Issue,
      MergePRConfig,
      Platform,
      PlatformParams,
      PlatformResult,
      Pr,
      RepoParams,
      RepoResult,
      UpdatePrConfig,
    } from '../types';
    import { smartTruncate } from '../utils/pr-body';
    import * as helper from './gitea-helper';
    import {
      getMergeMethod,
      getRepoUrl,
      smartLinks,
      trimTrailingApiPath,
    } from './utils';
    
    interface GiteaRepoConfig {
      repository: string;
      mergeMethod: helper.PRMergeMethod;
    
      prList: Promise<Pr[]> | null;
      issueList: Promise<Issue[]> | null;
      labelList: Promise<helper.Label[]> | null;
      defaultBranch: string;
      cloneSubmodules: boolean;
    }
    
    const DRAFT_PREFIX = 'WIP: ';
    
    const defaults = {
      hostType: PlatformId.Gitea,
      endpoint: 'https://gitea.com/',
      version: '0.0.0',
    };
    
    let config: GiteaRepoConfig = {} as any;
    let botUserID: number;
    let botUserName: string;
    
    function toRenovateIssue(data: helper.Issue): Issue {
      return {