From 893f7caab858ae0e90d29920f17e4dcc3f03bdca Mon Sep 17 00:00:00 2001
From: Kamil Kowalski <kamil@fresha.com>
Date: Mon, 28 Nov 2022 11:35:06 +0100
Subject: [PATCH] fix(manager/mix): comment handling in dependency extraction
 (#19142)

---
 lib/modules/manager/mix/__fixtures__/mix.exs | 3 +--
 lib/modules/manager/mix/extract.ts           | 4 ++--
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/lib/modules/manager/mix/__fixtures__/mix.exs b/lib/modules/manager/mix/__fixtures__/mix.exs
index 29966d7d9d..08fae9e3ca 100644
--- a/lib/modules/manager/mix/__fixtures__/mix.exs
+++ b/lib/modules/manager/mix/__fixtures__/mix.exs
@@ -15,8 +15,7 @@ defmodule MyProject.MixProject do
   end
 
   defp deps() do
-    [
-      #{:broadway_dashboard, "~> 0.2.2"},
+    [ #{:broadway_dashboard, "~> 0.2.2"},
 #{:broadway_dashboard, "~> 0.2.2"},
 #   {:broadway_dashboard, "~> 0.2.2"},
       #    {:broadway_dashboard, "~> 0.2.2"},
diff --git a/lib/modules/manager/mix/extract.ts b/lib/modules/manager/mix/extract.ts
index 0607e408b0..4867af6315 100644
--- a/lib/modules/manager/mix/extract.ts
+++ b/lib/modules/manager/mix/extract.ts
@@ -8,7 +8,7 @@ const depSectionRegExp = regEx(/defp\s+deps.*do/g);
 const depMatchRegExp = regEx(
   /{:(?<depName>\w+),\s*(?<datasource>[^:"]+)?:?\s*"(?<currentValue>[^"]+)",?\s*(?:organization: "(?<organization>.*)")?.*}/gm
 );
-const commentMatchRegExp = regEx(/^\s*#/);
+const commentMatchRegExp = regEx(/#.*$/);
 
 export async function extractPackageFile(
   content: string,
@@ -18,7 +18,7 @@ export async function extractPackageFile(
   const deps: PackageDependency[] = [];
   const contentArr = content
     .split(newlineRegex)
-    .filter((line) => !commentMatchRegExp.test(line));
+    .map((line) => line.replace(commentMatchRegExp, ''));
   for (let lineNumber = 0; lineNumber < contentArr.length; lineNumber += 1) {
     if (contentArr[lineNumber].match(depSectionRegExp)) {
       let depBuffer = '';
-- 
GitLab