def ext_git(abs_source, dest, inputhash, loader, resources, **kwargs):
    """ Clones a git repository """
    contents = yaml.load(render(abs_source, inputhash, loader))
    finalfile = get_filename(dest)

    jsonschema.validate(contents, SCHEMA)
    url = contents['url']

    refspec = None
    sshkey = None
    args = ''

    if contents in 'refspec':
        refspec = contents['refspec']
    if 'sshkey' in contents:
        sshkey = contents['sshkey']
    if 'args' in contents:
        args = contents['args']

    if sshkey:
        key = resources[sshkey]()
        if 'GIT_SSH' in os.environ:
            git_ssh = os.environ['GIT_SSH']
            reset_to_env = True
        else:
            git_ssh = 'ssh'
            reset_to_env = False

        keyfile = write_temp_file(key, '.key', False)
        wrapper = write_temp_file(SSH_WRAPPER.format(git_ssh, keyfile), '.sh', True)
 
        old_environ = os.environ.copy()
        try:
            os.environ['GIT_SSH'] = wrapper
            repo = _clone_repo(url, finalfile, args)
        finally:
            if reset_to_env:
                os.environ['GIT_SSH'] = git_ssh
            else:
                del os.environ['GIT_SSH']
            os.remove(keyfile)
            os.remove(wrapper)
    else:
        repo = _clone_repo(url, finalfile, args)

    if refspec:
        repo.git.checkout(refspec)

    return finalfile
dataset/ETHPy150Open gosquadron/squadron/squadron/exthandlers/makegit.py/ext_git/swapped operands of `in`