A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://python-gitlab.readthedocs.org/en/stable/gl_objects/commits.html below:

Commits - python-gitlab v6.2.0

Toggle table of contents sidebar

Commits Commits Reference Examples

List the commits for a project:

commits = project.commits.list(get_all=True)

You can use the ref_name, since and until filters to limit the results:

commits = project.commits.list(ref_name='my_branch', get_all=True)
commits = project.commits.list(since='2016-01-01T00:00:00Z', get_all=True)

List all commits for a project (see Pagination) on all branches:

commits = project.commits.list(get_all=True)

Create a commit:

# See https://docs.gitlab.com/api/commits#create-a-commit-with-multiple-files-and-actions
# for actions detail
data = {
    'branch': 'main',
    'commit_message': 'blah blah blah',
    'actions': [
        {
            'action': 'create',
            'file_path': 'README.rst',
            'content': open('path/to/file.rst').read(),
        },
        {
            # Binary files need to be base64 encoded
            'action': 'create',
            'file_path': 'logo.png',
            'content': base64.b64encode(open('logo.png', mode='r+b').read()).decode(),
            'encoding': 'base64',
        }
    ]
}

commit = project.commits.create(data)

Get a commit detail:

commit = project.commits.get('e3d5a71b')

Get the diff for a commit:

Cherry-pick a commit into another branch:

commit.cherry_pick(branch='target_branch')

Revert a commit on a given branch:

commit.revert(branch='target_branch')

Get the references the commit has been pushed to (branches and tags):

commit.refs()  # all references
commit.refs('tag')  # only tags
commit.refs('branch')  # only branches

Get the signature of the commit (if the commit was signed, e.g. with GPG or x509):

List the merge requests related to a commit:

Commit status Reference Examples

List the statuses for a commit:

statuses = commit.statuses.list(get_all=True)

Change the status of a commit:

commit.statuses.create({'state': 'success'})

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4