Skip to content

Commit

Permalink
handle slash added by maven on windows (#691)
Browse files Browse the repository at this point in the history
* Using a __post_init__ function for the dataclass generated init to
  take care of this for us.

Signed-off-by: Shawn Hurley <shawn@hurley.page>
  • Loading branch information
shawn-hurley authored Feb 26, 2025
1 parent e8cd1bd commit 983f7da
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import re
import subprocess # trunk-ignore(bandit/B404)
import sys
from abc import ABC, abstractmethod
from dataclasses import dataclass, field
from functools import cached_property
Expand Down Expand Up @@ -91,6 +92,12 @@ def from_match(
def compiler_error_message(self) -> str:
return self.message

def __post_init__(self) -> None:
if sys.platform == "win32":
regex = re.compile(r"^/[a-zA-Z]:")
if re.match(regex, self.file):
self.file = self.file.removeprefix("/")


class CollapsedMavenCompilerError(ABC, MavenCompilerError):
lines: list[int] | None = None
Expand Down Expand Up @@ -586,14 +593,15 @@ def catchall(output: str) -> OtherError:
file_path_pattern = re.compile(r"(/[^:\s]+)")
file_path_matches = file_path_pattern.findall(output)
file_path = file_path_matches[0] if file_path_matches else "unknown file"
return OtherError(
error = OtherError(
file=file_path,
line=-1,
column=-1,
message="Unknown error occurred during Maven build.",
details=[output],
parse_lines=output,
)
return error


def deduplicate_errors(errors: list[MavenCompilerError]) -> list[MavenCompilerError]:
Expand Down

0 comments on commit 983f7da

Please sign in to comment.