git.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:git-stacktrace 作者: pinterest 项目源码 文件源码
def pickaxe(snippet, git_range, filename=None):
    """Run git log -S <snippet> <git_range> <filename>

    Use git pickaxe to 'Look for differences that change the number of occurrences of the
    specified string'

    If filename is passed in only look in that file

    Return list of commits that modified that snippet
    """
    cmd = 'git', 'log', '-b', '--pretty=%H', '-S', six.u(snippet), git_range
    if filename:
        cmd = cmd + ('--', filename,)
    commits = run_command(*cmd).splitlines()
    commits = [(commit, line_removed(snippet, commit)) for commit in commits]
    # Couldn't find a good way to POSIX regex escape the code and use regex
    # pickaxe to match full lines, so filter out partial results here.
    # Filter out results that aren't a full line
    commits = [commit for commit in commits if commit[1] is not None]
    return commits
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号