<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def sanitize_git_path(self, uri, ref=None):
 """Take a git URI and ref and converts it to a directory safe path. Args: uri (string):
 git URI (e.g. git@github.com:foo/bar.git) ref (string):
 optional git ref to be appended to the path Returns: str: Directory name for the supplied uri """

        if uri.endswith('.git'):
            dir_name = uri[:-4]  # drop .git
        else:
            dir_name = uri
        dir_name = self.sanitize_uri_path(dir_name)
        if ref is not None:
            dir_name += "-%s" % ref
        return dir_name