code: def test_get_tags(path=None):
      from unittest.mock import patch
  
      gr = GitRepo(path, create=True)
      eq_(gr.get_tags(), [])
      eq_(gr.describe(), None)
  
      # Explicitly override the committer date because tests may set it to a
      # fixed value, but we want to check that the returned tags are sorted by
      # the date the tag (for annotaged tags) or commit (for lightweight tags)
      # was created.
      with patch.dict(
          "os.environ",
          {"GIT_COMMITTER_DATE": "Thu, 07 Apr 2005 22:13:13 +0200"},
      ):
          create_tree(gr.path, {"file": ""})
          gr.add("file")
          gr.commit(msg="msg")
          eq_(gr.get_tags(), [])
          eq_(gr.describe(), None)
  
          gr.tag("nonannotated")
          tags1 = [{"name": "nonannotated", "hexsha": gr.get_hexsha()}]
          eq_(gr.get_tags(), tags1)
          eq_(gr.describe(), None)
          eq_(gr.describe(tags=True), tags1[0]["name"])
  
      first_commit = gr.get_hexsha()
  
      with patch.dict(
          "os.environ",
          {"GIT_COMMITTER_DATE": "Fri, 08 Apr 2005 22:13:13 +0200"},
      ):
          create_tree(gr.path, {"file": "123"})
          gr.add("file")
          gr.commit(msg="changed")
  
      with patch.dict(
          "os.environ",
          {"GIT_COMMITTER_DATE": "Fri, 09 Apr 2005 22:13:13 +0200"},
      ):
          gr.tag("annotated", message="annotation")
      # The annotated tag happened later, so it comes last.
      tags2 = tags1 + [{"name": "annotated", "hexsha": gr.get_hexsha()}]
      eq_(gr.get_tags(), tags2)
      eq_(gr.describe(), tags2[1]["name"])
  
      # compare prev commit
      eq_(gr.describe(commitish=first_commit), None)
      eq_(
          gr.describe(commitish=first_commit, tags=True),
          tags1[0]["name"],
      )
  
      gr.tag("specific", commit="HEAD~1")
      eq_(gr.get_hexsha("specific"), gr.get_hexsha("HEAD~1"))
      assert_in("specific", gr.get_tags(output="name"))
  
      # retag a different commit
      assert_raises(CommandError, gr.tag, "specific", commit="HEAD")
      # force it
      gr.tag("specific", commit="HEAD", options=["-f"])
      eq_(gr.get_hexsha("specific"), gr.get_hexsha("HEAD"))
  
      # delete
      gr.call_git(["tag", "-d", "specific"])
      eq_(gr.get_tags(), tags2)
      # more than one
      gr.tag("one")
      gr.tag("two")
      gr.call_git(["tag", "-d", "one", "two"])
      eq_(gr.get_tags(), tags2)
  
imports: import logging
  import os
  import os.path
  import sys
  import pytest
  from datalad import get_encoding_info
  from datalad.cmd import StdOutCapture, StdOutErrCapture, WitlessRunner
  from datalad.support.exceptions import CommandError, FileNotInRepositoryError, InvalidGitRepositoryError, NoSuchPathError, PathKnownToRepositoryError
  from datalad.support.external_versions import external_versions
  from datalad.support.gitrepo import GitRepo, _normalize_path, normalize_paths, to_options
  from datalad.support.sshconnector import get_connection_hash
  from datalad.tests.utils_pytest import DEFAULT_BRANCH, DEFAULT_REMOTE, SkipTest, assert_cwd_unchanged, assert_equal, assert_false, assert_in, assert_in_results, assert_is_instance, assert_not_equal, assert_not_in, assert_raises, assert_repo_status, assert_true, create_tree, eq_, get_most_obscure_supported_name, integration, neq_, ok_, skip_if_no_network, skip_if_on_windows, skip_nomultiplex_ssh, slow, swallow_logs, with_tempfile, with_tree, xfail_buggy_annex_info
  from datalad.utils import Path, chpwd, getpwd, on_windows, rmtree
label_desc: Use image node_id 41 for calling a global function with example usage: test_get_tags(path) without return types