Skip to content

Commit

Permalink
fix(manager/sbt): allow star comment (#17005)
Browse files Browse the repository at this point in the history
* fix: sbt manager allow star comment

* Update lib/modules/manager/sbt/extract.ts

Co-authored-by: Sergei Zharinov <zharinov@users.noreply.github.com>

* add test case

* prettier-fix

Co-authored-by: Sergei Zharinov <zharinov@users.noreply.github.com>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
Co-authored-by: Rhys Arkins <rhys@arkins.net>
  • Loading branch information
4 people committed Aug 6, 2022
1 parent c4726ab commit b367f4d
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
40 changes: 40 additions & 0 deletions lib/modules/manager/sbt/extract.spec.ts
Expand Up @@ -258,5 +258,45 @@ describe('modules/manager/sbt/extract', () => {
packageFileVersion: undefined,
});
});

it('extract deps with comment', () => {
const content = `
name := "service"
scalaVersion := "2.13.8" // scalaVersion
lazy val compileDependencies =
Seq(
"com.typesafe.scala-logging" %% "scala-logging" % "3.9.4", /** critical lib */
"ch.qos.logback" % "logback-classic" % "1.2.10" // common lib
)
`;
expect(extractPackageFile(content)).toMatchObject({
deps: [
{
registryUrls: ['https://repo.maven.apache.org/maven2'],
datasource: 'maven',
depName: 'scala',
packageName: 'org.scala-lang:scala-library',
currentValue: '2.13.8',
separateMinorPatch: true,
},
{
registryUrls: ['https://repo.maven.apache.org/maven2'],
depName: 'com.typesafe.scala-logging:scala-logging',
packageName: 'com.typesafe.scala-logging:scala-logging_2.13',
currentValue: '3.9.4',
datasource: 'sbt-package',
},
{
registryUrls: ['https://repo.maven.apache.org/maven2'],
depName: 'ch.qos.logback:logback-classic',
packageName: 'ch.qos.logback:logback-classic',
currentValue: '1.2.10',
datasource: 'sbt-package',
},
],
packageFileVersion: undefined,
});
});
});
});
2 changes: 1 addition & 1 deletion lib/modules/manager/sbt/extract.ts
Expand Up @@ -12,7 +12,7 @@ import type { PackageDependency, PackageFile } from '../types';
import type { ParseContext, ParseOptions } from './types';

const stripComment = (str: string): string =>
str.replace(regEx(/(^|\s+)\/\/.*$/), '');
str.replace(regEx(/(?:^|\s+)\/\/.*$/), '').replace(regEx(/\/\*.*?\*\//g), '');

const isSingleLineDep = (str: string): boolean =>
regEx(/^\s*(libraryDependencies|dependencyOverrides)\s*\+=\s*/).test(str);
Expand Down

0 comments on commit b367f4d

Please sign in to comment.