from typing import List
from typing import Tuple
from pathlib import Path
import fnmatch


def get_ignore_regex(ignore_rules: List[Tuple[str, str]], regexes: List[str], logfile: Path) -> str:
    """Combine together regex for the given log file using file specific and global ignore rules."""
    regex_list = regexes[:]
    for record in ignore_rules:
        files_glob, regex = record
        if fnmatch.filter([logfile.name], files_glob):
            regex_list.append(regex)
    return "|".join(regex_list)