Example #1
0
def get_unique_commit_hashes(ref_name, new_rev):
    """Returns a list of abbreviated commit hashes unique to ref_name."""
    git_command = [
        'git', 'rev-list', new_rev, '--abbrev-commit', '--reverse', '--not'
    ]
    git_command.extend(get_excluded_branches(ref_name))
    return execute(git_command).strip().split('\n')
Example #2
0
def get_commit_hashes(old_rev, new_rev):
    """Returns a list of abbreviated commit hashes from old_rev to new_rev."""
    git_command = [
        'git', 'rev-list', '--abbrev-commit', '--reverse',
        '%s..%s' % (old_rev, new_rev)
    ]
    return execute(git_command).split('\n')
Example #3
0
def get_commit_message(commit):
    """Returns the specified commit's commit message."""
    git_command = ['git', 'show', '-s', '--pretty=format:%B', commit]
    return execute(git_command).strip()
Example #4
0
def get_branches_containing_commit(commit_hash):
    """Returns a list of all branches containing the specified commit."""
    git_command = ['git', 'branch', '--contains', commit_hash]
    branches = execute(git_command).replace('*', '').split('\n')
    return [branch.strip() for branch in branches]
Example #5
0
def get_excluded_branches(ref_name):
    """Returns a list of all branches, excluding the specified branch."""
    git_command = ['git', 'for-each-ref', 'refs/heads/', '--format=%(refname)']
    all_branches = execute(git_command).strip().split('\n')
    return [branch.strip() for branch in all_branches if branch != ref_name]
Example #6
0
def get_unique_commit_hashes(ref_name, new_rev):
    """Returns a list of abbreviated commit hashes unique to ref_name."""
    git_command = ['git', 'rev-list', new_rev, '--abbrev-commit', '--reverse',
                   '--not']
    git_command.extend(get_excluded_branches(ref_name))
    return execute(git_command).strip().split('\n')
Example #7
0
def get_commit_hashes(old_rev, new_rev):
    """Returns a list of abbreviated commit hashes from old_rev to new_rev."""
    git_command = ['git', 'rev-list', '--abbrev-commit', '--reverse', '%s..%s'
                   % (old_rev, new_rev)]
    return execute(git_command).split('\n')
Example #8
0
def get_commit_message(commit):
    """Returns the specified commit's commit message."""
    git_command = ['git', 'show', '-s', '--pretty=format:%B', commit]
    return execute(git_command).strip()
Example #9
0
def get_branches_containing_commit(commit_hash):
    """Returns a list of all branches containing the specified commit."""
    git_command = ['git', 'branch', '--contains', commit_hash]
    branches = execute(git_command).replace('*', '').split('\n')
    return [branch.strip() for branch in branches]
Example #10
0
def get_excluded_branches(ref_name):
    """Returns a list of all branches, excluding the specified branch."""
    git_command = ['git', 'for-each-ref', 'refs/heads/', '--format=%(refname)']
    all_branches = execute(git_command).strip().split('\n')
    return [branch.strip() for branch in all_branches if branch != ref_name]