Skip to content

Commit

Permalink
feat(manager/maven): provide warning log if pom contains windows line…
Browse files Browse the repository at this point in the history
… ending (#31858)

Co-authored-by: Sebastian Panse <[email protected]>
Co-authored-by: Rhys Arkins <[email protected]>
  • Loading branch information
3 people authored Oct 15, 2024
1 parent be837b6 commit fbc3ba8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/modules/manager/maven/extract.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { codeBlock } from 'common-tags';
import { Fixtures } from '../../../../test/fixtures';
import { fs } from '../../../../test/util';
import { logger } from '../../../logger';
import {
extractAllPackageFiles,
extractExtensions,
Expand Down Expand Up @@ -234,6 +235,17 @@ describe('modules/manager/maven/extract', () => {
});
});

it('extract dependencies with windows line endings', () => {
const logSpy = jest.spyOn(logger, 'warn');
extractPackage(
'<?xml version="1.0" encoding="UTF-8"?> \r\n',
'some-file',
);
expect(logSpy).toHaveBeenCalledWith(
'Your pom.xml contains windows line endings. This is not supported and may result in parsing issues.',
);
});

it('tries minimum manifests', () => {
const res = extractPackage(Fixtures.get('minimum.pom.xml'), 'some-file');
expect(res).toEqual({
Expand Down
5 changes: 5 additions & 0 deletions lib/modules/manager/maven/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ function parsePom(raw: string, packageFile: string): XmlDocument | null {
let project: XmlDocument;
try {
project = new XmlDocument(raw);
if (raw.includes('\r\n')) {
logger.warn(
'Your pom.xml contains windows line endings. This is not supported and may result in parsing issues.',
);
}
} catch {
logger.debug({ packageFile }, `Failed to parse as XML`);
return null;
Expand Down

0 comments on commit fbc3ba8

Please sign in to comment.