def replace_git_url(generator):
template = g_jinja2.get_template(GIT_TEMPLATE)<EOL>should_cache = generator.context.get('<STR_LIT>')<EOL>cache_location = generator.context.get('<STR_LIT>')<EOL>for article in generator.articles:<EOL><INDENT>for match in git_regex.findall(article._content):<EOL><INDENT>params = collections.defaultdict(str)<EOL>repo = match[<NUM_LIT:1>]<EOL>filename = match[<NUM_LIT:3>]<EOL>branch = match[<NUM_LIT:5>]<EOL>hash = match[<NUM_LIT:7>]<EOL>params['<STR_LIT>'] = match[<NUM_LIT:1>]<EOL>params['<STR_LIT:filename>'] = match[<NUM_LIT:3>]<EOL>if match[<NUM_LIT:5>]:<EOL><INDENT>params['<STR_LIT>'] = match[<NUM_LIT:5>]<EOL><DEDENT>if match[<NUM_LIT:7>]:<EOL><INDENT>params['<STR_LIT>'] = match[<NUM_LIT:7>]<EOL><DEDENT>logger.info('<STR_LIT>'.format(repo, filename, branch, hash))<EOL>logger.info('<STR_LIT>'.format(params))<EOL>body = None if not should_cache else get_cache(cache_location, **params)<EOL>if not body:<EOL><INDENT>logger.info('<STR_LIT>')<EOL>response = fetch_git(**params)<EOL>body = get_body(response)<EOL>if should_cache:<EOL><INDENT>logger.info('<STR_LIT>')<EOL>cache_params = copy.copy(params)<EOL>cache_params['<STR_LIT:body>'] = body<EOL>set_cache(cache_location, **cache_params)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>logger.info('<STR_LIT>')<EOL><DEDENT>context = generator.context.copy()<EOL>context.update({<EOL>'<STR_LIT:code>': body,<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': __url__,<EOL>'<STR_LIT:filename>': filename,<EOL>'<STR_LIT:url>': git_url(**params)<EOL>})<EOL>replacement = template.render(context)<EOL>article._content = article._content.replace(match[<NUM_LIT:0>], replacement)<EOL><DEDENT><DEDENT>
Replace gist tags in the article content.