From 9f8653588fcd6ba3c1b9b9fd04f5d92df137abdb Mon Sep 17 00:00:00 2001 From: Eric Date: Tue, 1 Apr 2025 14:35:41 -0700 Subject: [PATCH] Fix pathing issue and use actual path objects instead of strings for nicer typing and more pythonic code --- contentctl/actions/release_notes.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/contentctl/actions/release_notes.py b/contentctl/actions/release_notes.py index d9272129..a43ede8b 100644 --- a/contentctl/actions/release_notes.py +++ b/contentctl/actions/release_notes.py @@ -1,10 +1,12 @@ -from contentctl.objects.config import release_notes -from git import Repo -import re -import yaml import pathlib +import re from typing import List, Union +import yaml +from git import Repo + +from contentctl.objects.config import release_notes + class ReleaseNotes: def create_notes( @@ -171,13 +173,13 @@ def create_notes( def release_notes(self, config: release_notes) -> None: ### Remove hard coded path - directories = [ - "detections/", - "stories/", - "macros/", - "lookups/", - "playbooks/", - "ssa_detections/", + directories: list[pathlib.Path] = [ + config.path / "detections", + config.path / "stories", + config.path / "macros", + config.path / "lookups", + config.path / "playbooks", + config.path / "ssa_detections", ] repo = Repo(config.path) @@ -229,7 +231,7 @@ def release_notes(self, config: release_notes) -> None: file_path = pathlib.Path(diff.a_path) # Check if the file is in the specified directories - if any(str(file_path).startswith(directory) for directory in directories): + if any(file_path.is_relative_to(directory) for directory in directories): # Check if a file is Modified if diff.change_type == "M": modified_files.append(file_path)