def harvest_repo(root_url, archive_path, tag=None, archive_format='<STR_LIT>'):
if not git_exists():<EOL><INDENT>raise Exception("<STR_LIT>")<EOL><DEDENT>clone_path = mkdtemp(dir=cfg['<STR_LIT>'])<EOL>git = get_which_git()<EOL>call([git, '<STR_LIT>', root_url, clone_path])<EOL>chdir(clone_path)<EOL>if tag:<EOL><INDENT>call([git, '<STR_LIT>', '<STR_LIT>' + archive_format, '<STR_LIT>',<EOL>archive_path, tag])<EOL><DEDENT>else:<EOL><INDENT>call([git, '<STR_LIT>', '<STR_LIT>' + archive_format, '<STR_LIT>',<EOL>archive_path, '<STR_LIT>'])<EOL><DEDENT>try:<EOL><INDENT>rmtree(clone_path)<EOL><DEDENT>except OSError as e:<EOL><INDENT>if e.errno != errno.ENOENT:<EOL><INDENT>raise<EOL><DEDENT><DEDENT>
Archives a specific tag in a specific Git repository.

:param root_url: The URL to the Git repo
- Supported protocols: git, ssh, http[s].
:param archive_path: A temporary path to clone the repo to
- Must end in .git
:param tag: The path to which the .tar.gz will go to
- Must end in the same as format (NOT inside clone_path)
:param format: One of the following: tar.gz / tar / zip