From 82ca814747b88725bd0eb9b5ef91ed127b4c62f4 Mon Sep 17 00:00:00 2001
From: Rhys Arkins <rhys@arkins.net>
Date: Tue, 5 May 2020 20:42:14 +0200
Subject: [PATCH] refactor: remove unused branchName param in getFileList

---
 lib/platform/azure/index.ts                         | 9 ++-------
 lib/platform/bitbucket-server/index.ts              | 8 ++------
 lib/platform/bitbucket/index.ts                     | 6 ++----
 lib/platform/bitbucket/utils.ts                     | 1 -
 lib/platform/git/__snapshots__/storage.spec.ts.snap | 9 ---------
 lib/platform/git/storage.spec.ts                    | 4 ----
 lib/platform/git/storage.ts                         | 8 ++------
 lib/platform/gitea/index.ts                         | 2 +-
 lib/platform/github/index.ts                        | 4 ++--
 lib/platform/gitlab/index.ts                        | 4 ++--
 10 files changed, 13 insertions(+), 42 deletions(-)

diff --git a/lib/platform/azure/index.ts b/lib/platform/azure/index.ts
index 903c723509..711fd0ba3d 100644
--- a/lib/platform/azure/index.ts
+++ b/lib/platform/azure/index.ts
@@ -48,7 +48,6 @@ interface Config {
   project: string;
   azureWorkItemId: string;
   prList: Pr[];
-  fileList: null;
   repository: string;
 }
 
@@ -182,10 +181,8 @@ export function getRepoForceRebase(): Promise<boolean> {
 
 // Search
 
-export /* istanbul ignore next */ function getFileList(
-  branchName?: string
-): Promise<string[]> {
-  return config.storage.getFileList(branchName);
+export /* istanbul ignore next */ function getFileList(): Promise<string[]> {
+  return config.storage.getFileList();
 }
 
 export /* istanbul ignore next */ async function setBaseBranch(
@@ -194,9 +191,7 @@ export /* istanbul ignore next */ async function setBaseBranch(
   logger.debug(`Setting baseBranch to ${branchName}`);
   config.baseBranch = branchName;
   delete config.baseCommitSHA;
-  delete config.fileList;
   const baseBranchSha = await config.storage.setBaseBranch(branchName);
-  await getFileList(branchName);
   return baseBranchSha;
 }
 
diff --git a/lib/platform/bitbucket-server/index.ts b/lib/platform/bitbucket-server/index.ts
index 2d5f726bc5..3cdd5b269b 100644
--- a/lib/platform/bitbucket-server/index.ts
+++ b/lib/platform/bitbucket-server/index.ts
@@ -49,7 +49,6 @@ interface BbsConfig {
   baseBranch: string;
   bbUseDefaultReviewers: boolean;
   defaultBranch: string;
-  fileList: any[];
   mergeMethod: string;
   owner: string;
   prList: Pr[];
@@ -273,11 +272,8 @@ export /* istanbul ignore next */ function setBranchPrefix(
 // Search
 
 // Get full file list
-export function getFileList(
-  branchName: string = config.baseBranch
-): Promise<string[]> {
-  logger.debug(`getFileList(${branchName})`);
-  return config.storage.getFileList(branchName);
+export function getFileList(): Promise<string[]> {
+  return config.storage.getFileList();
 }
 
 // Branch
diff --git a/lib/platform/bitbucket/index.ts b/lib/platform/bitbucket/index.ts
index d516a162c3..45f13da74f 100644
--- a/lib/platform/bitbucket/index.ts
+++ b/lib/platform/bitbucket/index.ts
@@ -173,8 +173,8 @@ export function getRepoForceRebase(): Promise<boolean> {
 // Search
 
 // Get full file list
-export function getFileList(branchName?: string): Promise<string[]> {
-  return config.storage.getFileList(branchName);
+export function getFileList(): Promise<string[]> {
+  return config.storage.getFileList();
 }
 
 export async function setBaseBranch(
@@ -183,9 +183,7 @@ export async function setBaseBranch(
   logger.debug(`Setting baseBranch to ${branchName}`);
   config.baseBranch = branchName;
   delete config.baseCommitSHA;
-  delete config.fileList;
   const baseBranchSha = await config.storage.setBaseBranch(branchName);
-  await getFileList(branchName);
   return baseBranchSha;
 }
 
diff --git a/lib/platform/bitbucket/utils.ts b/lib/platform/bitbucket/utils.ts
index 1461bf2860..c4721cbbee 100644
--- a/lib/platform/bitbucket/utils.ts
+++ b/lib/platform/bitbucket/utils.ts
@@ -9,7 +9,6 @@ export interface Config {
   baseBranch: string;
   baseCommitSHA: string;
   defaultBranch: string;
-  fileList: any[];
   has_issues: boolean;
   mergeMethod: string;
   owner: string;
diff --git a/lib/platform/git/__snapshots__/storage.spec.ts.snap b/lib/platform/git/__snapshots__/storage.spec.ts.snap
index bc7b2e88b0..d008e251b5 100644
--- a/lib/platform/git/__snapshots__/storage.spec.ts.snap
+++ b/lib/platform/git/__snapshots__/storage.spec.ts.snap
@@ -21,15 +21,6 @@ Array [
 `;
 
 exports[`platform/git/storage getFileList() should return the correct files 1`] = `
-Array [
-  "file_to_delete",
-  "future_file",
-  "master_file",
-  "past_file",
-]
-`;
-
-exports[`platform/git/storage getFileList() should return the correct files 2`] = `
 Array [
   "file_to_delete",
   "master_file",
diff --git a/lib/platform/git/storage.spec.ts b/lib/platform/git/storage.spec.ts
index bac0b0c7c8..2a299e636b 100644
--- a/lib/platform/git/storage.spec.ts
+++ b/lib/platform/git/storage.spec.ts
@@ -82,11 +82,7 @@ describe('platform/git/storage', () => {
     });
   });
   describe('getFileList()', () => {
-    it('returns empty array if error', async () => {
-      expect(await git.getFileList('not_found')).toEqual([]);
-    });
     it('should return the correct files', async () => {
-      expect(await git.getFileList('renovate/future_branch')).toMatchSnapshot();
       expect(await git.getFileList()).toMatchSnapshot();
     });
     it('should exclude submodules', async () => {
diff --git a/lib/platform/git/storage.ts b/lib/platform/git/storage.ts
index 3f3757c35c..8e11ffa6b8 100644
--- a/lib/platform/git/storage.ts
+++ b/lib/platform/git/storage.ts
@@ -301,12 +301,8 @@ export class Storage {
     }
   }
 
-  async getFileList(branchName?: string): Promise<string[]> {
-    const branch = branchName || this._config.baseBranch;
-    const exists = await this.branchExists(branch);
-    if (!exists) {
-      return [];
-    }
+  async getFileList(): Promise<string[]> {
+    const branch = this._config.baseBranch;
     const submodules = await this.getSubmodules();
     const files: string = await this._git.raw([
       'ls-tree',
diff --git a/lib/platform/gitea/index.ts b/lib/platform/gitea/index.ts
index cbdc65eb0f..e50378ddf0 100644
--- a/lib/platform/gitea/index.ts
+++ b/lib/platform/gitea/index.ts
@@ -929,7 +929,7 @@ const platform: Platform = {
   },
 
   getFileList(): Promise<string[]> {
-    return config.storage.getFileList(config.baseBranch);
+    return config.storage.getFileList();
   },
 
   getAllRenovateBranches(branchPrefix: string): Promise<string[]> {
diff --git a/lib/platform/github/index.ts b/lib/platform/github/index.ts
index d1080f761c..9a1e7d5be4 100644
--- a/lib/platform/github/index.ts
+++ b/lib/platform/github/index.ts
@@ -535,8 +535,8 @@ export function setBranchPrefix(branchPrefix: string): Promise<void> {
 // Search
 
 // istanbul ignore next
-export function getFileList(branchName = config.baseBranch): Promise<string[]> {
-  return config.storage.getFileList(branchName);
+export function getFileList(): Promise<string[]> {
+  return config.storage.getFileList();
 }
 
 // Branch
diff --git a/lib/platform/gitlab/index.ts b/lib/platform/gitlab/index.ts
index e3c620e7b2..e5418ad2a4 100644
--- a/lib/platform/gitlab/index.ts
+++ b/lib/platform/gitlab/index.ts
@@ -286,8 +286,8 @@ export /* istanbul ignore next */ function setBranchPrefix(
 // Search
 
 // Get full file list
-export function getFileList(branchName = config.baseBranch): Promise<string[]> {
-  return config.storage.getFileList(branchName);
+export function getFileList(): Promise<string[]> {
+  return config.storage.getFileList();
 }
 
 // Returns true if branch exists, otherwise false
-- 
GitLab