<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def git_tag_list(pattern=None):
 """ Return a list of all the tags in the git repo matching a regex passed in `pattern`. If `pattern` is None, return all the tags. """

    with chdir(get_root()):
        result = run_command('git tag', capture=True).stdout
        result = result.splitlines()

    if not pattern:
        return result

    regex = re.compile(pattern)
    return list(filter(regex.search, result))