def getRepositoryCommand(directory):
    """
    Detect the VCS used in the specified directory and return either a
    L{SVNCommand} or a L{GitCommand} if the directory is a Subversion checkout
    or a Git repository, respectively.
    If the directory is neither one nor the other, it raises a
    L{NotWorkingDirectory} exception.

    @type directory: L{FilePath}
    @param directory: The directory to detect the VCS used from.

    @rtype: L{SVNCommand} or L{GitCommand}

    @raise NotWorkingDirectory: if no supported VCS can be found from the
        specified directory.
    """
    try:
        SVNCommand.ensureIsWorkingDirectory(directory)
        return SVNCommand
    except (NotWorkingDirectory, OSError):
        # It's not SVN, but that's okay, eat the error
        pass

    try:
        GitCommand.ensureIsWorkingDirectory(directory)
        return GitCommand
    except (NotWorkingDirectory, __HOLE__):
        # It's not Git, but that's okay, eat the error
        pass

    raise NotWorkingDirectory("No supported VCS can be found in %s" %
                              (directory.path,))
dataset/ETHPy150Open twisted/twisted/twisted/python/_release.py/getRepositoryCommand