From 07c005869cc738fc7e3f7786011d97511c386014 Mon Sep 17 00:00:00 2001
From: Rhys Arkins <rhys@arkins.net>
Date: Sat, 14 Dec 2024 11:32:51 +0100
Subject: [PATCH] feat: extend skipStage to extract, lookup (#33108)

---
 lib/modules/manager/types.ts                     | 8 +++++++-
 lib/types/index.ts                               | 2 +-
 lib/types/skip-reason.ts                         | 2 ++
 lib/workers/repository/process/extract-update.ts | 4 ++++
 lib/workers/repository/process/fetch.spec.ts     | 3 +++
 lib/workers/repository/process/fetch.ts          | 3 +++
 6 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/lib/modules/manager/types.ts b/lib/modules/manager/types.ts
index a1e8ba2824..2ce51aa306 100644
--- a/lib/modules/manager/types.ts
+++ b/lib/modules/manager/types.ts
@@ -6,7 +6,12 @@ import type {
   ValidationMessage,
 } from '../../config/types';
 import type { Category } from '../../constants';
-import type { ModuleApi, RangeStrategy, SkipReason } from '../../types';
+import type {
+  ModuleApi,
+  RangeStrategy,
+  SkipReason,
+  StageName,
+} from '../../types';
 import type { FileChange } from '../../util/git/types';
 import type { MergeConfidence } from '../../util/merge-confidence/types';
 import type { CustomExtractConfig } from './custom/types';
@@ -144,6 +149,7 @@ export interface PackageDependency<T = Record<string, any>>
   registryUrls?: string[] | null;
   rangeStrategy?: RangeStrategy;
   skipReason?: SkipReason;
+  skipStage?: StageName;
   sourceLine?: number;
   newVersion?: string;
   updates?: LookupUpdate[];
diff --git a/lib/types/index.ts b/lib/types/index.ts
index a111c9ade7..4b6a903608 100644
--- a/lib/types/index.ts
+++ b/lib/types/index.ts
@@ -1,6 +1,6 @@
 export type { CommitMessageJSON } from './commit-message-json';
 export type { HostRule, CombinedHostRule } from './host-rules';
-export type { SkipReason } from './skip-reason';
+export type { SkipReason, StageName } from './skip-reason';
 export type { RangeStrategy } from './versioning';
 export type { BranchStatus } from './branch-status';
 export type {
diff --git a/lib/types/skip-reason.ts b/lib/types/skip-reason.ts
index 534d37b445..8ebf4568e4 100644
--- a/lib/types/skip-reason.ts
+++ b/lib/types/skip-reason.ts
@@ -50,8 +50,10 @@ export type SkipReason =
 export type StageName =
   | 'current-timestamp'
   | 'datasource-merge'
+  | 'extract'
   | 'lock-file-maintenance-merge'
   | 'lock-file-maintenance-merge-2'
+  | 'lookup'
   | 'pre-lookup'
   | 'source-url'
   | 'update-type'
diff --git a/lib/workers/repository/process/extract-update.ts b/lib/workers/repository/process/extract-update.ts
index e31b055a9e..75aecabd65 100644
--- a/lib/workers/repository/process/extract-update.ts
+++ b/lib/workers/repository/process/extract-update.ts
@@ -128,6 +128,10 @@ export async function extract(
         for (const file of files) {
           for (const dep of file.deps) {
             delete dep.updates;
+            if (dep.skipStage && dep.skipStage !== 'extract') {
+              delete dep.skipReason;
+              delete dep.skipStage;
+            }
           }
         }
       }
diff --git a/lib/workers/repository/process/fetch.spec.ts b/lib/workers/repository/process/fetch.spec.ts
index f891c6e81e..e68a4ce76f 100644
--- a/lib/workers/repository/process/fetch.spec.ts
+++ b/lib/workers/repository/process/fetch.spec.ts
@@ -59,18 +59,21 @@ describe('workers/repository/process/fetch', () => {
                 depName: 'abcd',
                 packageName: 'abcd',
                 skipReason: 'ignored',
+                skipStage: 'lookup',
                 updates: [],
               },
               {
                 depName: 'foo',
                 packageName: 'foo',
                 skipReason: 'disabled',
+                skipStage: 'lookup',
                 updates: [],
               },
               {
                 depName: 'skipped',
                 packageName: 'skipped',
                 skipReason: 'some-reason',
+                skipStage: 'lookup',
                 updates: [],
               },
             ],
diff --git a/lib/workers/repository/process/fetch.ts b/lib/workers/repository/process/fetch.ts
index e9b17a4470..36fd712277 100644
--- a/lib/workers/repository/process/fetch.ts
+++ b/lib/workers/repository/process/fetch.ts
@@ -172,6 +172,9 @@ export async function fetchUpdates(
         deps = [];
         packageDeps.set(packageFile, deps);
       }
+      if (dep.skipReason && !dep.skipStage) {
+        dep.skipStage = 'lookup';
+      }
       deps.push(dep);
     } else {
       errors.push(err);
-- 
GitLab