

def add_to_gitignore(self, repo, patterns):
    gitignore = os.path.join(repo, '.gitignore')
    contents = []
    if os.path.exists(repo):
        with open(gitignore, 'r+') as f:
            contents = [l.strip() for l in f]
    logger.debug('Initial .gitignore: %s', contents)
    for p in patterns:
        if (p not in contents):
            logger.debug('Adding to .gitignore: %s', p)
            contents.append(p)
    contents.append('')
    with open(gitignore, 'w+') as f:
        f.write('\n'.join(contents))
    logger.debug('Final .gitignore: %s', contents)
    return contents

dataset/ETHPy150Open SublimeGit/SublimeGit/sgit/status.py GitStatusIgnoreCommand.add_to_gitignore/VarMisuse@39/47 `gitignore`->`repo`