diff --git a/scantags.py b/scantags.py index d6bc1aa..1faa6f7 100644 --- a/scantags.py +++ b/scantags.py @@ -93,6 +93,16 @@ def grep_file(filename: str, line_regex: re.Pattern) -> Iterator[tuple[str, int, pass +def grep_files( + directory: str, filenames: list[str], line_regex: re.Pattern +) -> Iterator[tuple[str, int, str]]: + """ + Grep files + """ + for filename in filenames: + yield from grep_file(os.path.join(directory, filename), line_regex) + + def grep_dir( directory: str, line_regex: re.Pattern, @@ -150,12 +160,7 @@ def process_line( futures = [] for file, line_number, tag in chain( grep_dir(directory, LINE_REGEX, FILE_PATTERN, IGNORE_DIRECTORIES), - *map( - lambda f: grep_file( - os.path.join(directory, f), re.compile(f"({TAG_REGEX})") - ), - INCLUDE_FILES, - ), + grep_files(directory, INCLUDE_FILES, re.compile(f"({TAG_REGEX})")), ): file = file.removeprefix(f"{directory}/") futures.append(executor.submit(process_line, file, line_number, tag)) diff --git a/services/__init__.py b/services/__init__.py index fd06038..ab61be2 100644 --- a/services/__init__.py +++ b/services/__init__.py @@ -105,8 +105,8 @@ def get_urltag(string: str) -> dict[str, str] | None: issue_id = parse_qs(url.query)["id"][0] elif not path.startswith("issues/") and "/issue" in path: # Support Bitbucket optional description after issue number - if not os.path.basename(path).isdigit(): - path = os.path.dirname(path) + if not re.search("/[0-9]+$", path): + path = path.rsplit("/", 1)[0] # Gitlab stuff path = path.replace("/-/", "/") repo, _, issue_id = path.rsplit("/", 2)