From f0ba97b6c26a020716f53154d09c074e77281604 Mon Sep 17 00:00:00 2001
From: Rhys Arkins <rhys@arkins.net>
Date: Tue, 22 Sep 2020 12:20:15 +0200
Subject: [PATCH] fix: Revert "refactor: write branches cache"

This reverts commit 266534eb725b590faa9e588091f790fdd9a01c73.
---
 lib/manager/common.ts              |  1 -
 lib/util/cache/repository/index.ts | 23 ----------
 lib/workers/repository/cache.ts    | 67 ------------------------------
 lib/workers/repository/index.ts    |  2 -
 4 files changed, 93 deletions(-)
 delete mode 100644 lib/workers/repository/cache.ts

diff --git a/lib/manager/common.ts b/lib/manager/common.ts
index 57f36f7453..1cb67931e6 100644
--- a/lib/manager/common.ts
+++ b/lib/manager/common.ts
@@ -158,7 +158,6 @@ export interface PackageDependency<T = Record<string, any>> extends Package<T> {
   digestOneAndOnly?: boolean;
   displayFrom?: string;
   displayTo?: string;
-  fixedVersion?: string;
   fromVersion?: string;
   lockedVersion?: string;
   propSource?: string;
diff --git a/lib/util/cache/repository/index.ts b/lib/util/cache/repository/index.ts
index 9258fbc2de..0612ab0dc6 100644
--- a/lib/util/cache/repository/index.ts
+++ b/lib/util/cache/repository/index.ts
@@ -11,30 +11,7 @@ export interface BaseBranchCache {
   packageFiles: PackageFile[]; // extract result
 }
 
-export interface BranchUpgradeCache {
-  currentDigest?: string;
-  currentValue?: string;
-  datasource?: string;
-  depName?: string;
-  fixedVersion?: string;
-  fromVersion?: string;
-  lookupName?: string;
-  newDigest?: string;
-  newValue?: string;
-  toVersion?: string;
-}
-
-export interface BranchCache {
-  automerge: boolean;
-  branchName: string;
-  isModified: boolean;
-  prNo: number | null;
-  sha: string | null;
-  upgrades: BranchUpgradeCache[];
-}
-
 export interface Cache {
-  branches?: BranchCache[];
   repository?: string;
   init?: RepoInitConfig;
   scan?: Record<string, BaseBranchCache>;
diff --git a/lib/workers/repository/cache.ts b/lib/workers/repository/cache.ts
deleted file mode 100644
index 932571f61e..0000000000
--- a/lib/workers/repository/cache.ts
+++ /dev/null
@@ -1,67 +0,0 @@
-/* istanbul ignore file */
-
-import { logger } from '../../logger';
-import { platform } from '../../platform';
-import {
-  BranchCache,
-  BranchUpgradeCache,
-  getCache,
-} from '../../util/cache/repository';
-import { getBranchCommit, isBranchModified } from '../../util/git';
-import { BranchConfig, BranchUpgradeConfig } from '../common';
-
-function generateBranchUpgradeCache(
-  upgrade: BranchUpgradeConfig
-): BranchUpgradeCache {
-  const {
-    datasource,
-    depName,
-    lookupName,
-    fixedVersion,
-    fromVersion,
-    toVersion,
-    currentDigest,
-    newDigest,
-  } = upgrade;
-  return {
-    datasource,
-    depName,
-    lookupName,
-    fixedVersion,
-    fromVersion,
-    toVersion,
-    currentDigest,
-    newDigest,
-  };
-}
-
-async function generateBranchCache(branch: BranchConfig): Promise<BranchCache> {
-  const { branchName } = branch;
-  try {
-    const sha = getBranchCommit(branchName) || null;
-    let prNo = null;
-    if (sha) {
-      const branchPr = await platform.getBranchPr(branchName);
-      if (branchPr) {
-        prNo = branchPr.number;
-      }
-    }
-    const automerge = !!branch.automerge;
-    const isModified = await isBranchModified(branchName);
-    const upgrades: BranchUpgradeCache[] = branch.upgrades
-      ? branch.upgrades.map(generateBranchUpgradeCache)
-      : [];
-    return { branchName, sha, prNo, automerge, isModified, upgrades };
-  } catch (err) {
-    logger.error({ err, branchName }, 'Error generating branch cache');
-    return null;
-  }
-}
-
-export async function setBranchCache(branches: BranchConfig[]): Promise<void> {
-  const branchCache: BranchCache[] = [];
-  for (const branch of branches) {
-    branchCache.push(await generateBranchCache(branch));
-  }
-  getCache().branches = branchCache.filter(Boolean);
-}
diff --git a/lib/workers/repository/index.ts b/lib/workers/repository/index.ts
index 97a97dabc1..07c297529a 100644
--- a/lib/workers/repository/index.ts
+++ b/lib/workers/repository/index.ts
@@ -3,7 +3,6 @@ import { RenovateConfig } from '../../config';
 import { logger, setMeta } from '../../logger';
 import { deleteLocalFile } from '../../util/fs';
 import { addSplit, getSplits, splitInit } from '../../util/split';
-import { setBranchCache } from './cache';
 import { ensureMasterIssue } from './dependency-dashboard';
 import handleError from './error';
 import { finaliseRepo } from './finalise';
@@ -42,7 +41,6 @@ export async function renovateRepository(
     await ensureOnboardingPr(config, packageFiles, branches);
     const res = await updateRepo(config, branches);
     addSplit('update');
-    await setBranchCache(branches);
     if (res !== 'automerged') {
       await ensureMasterIssue(config, branches);
     }
-- 
GitLab