| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent f0fbefe commit 07c5594
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,6 +6,7 @@ API objects manipulation | |||
| 6 | 6 | ||
| 7 | 7 | gl_objects/branches | |
| 8 | 8 | gl_objects/builds | |
| 9 | + gl_objects/commits | ||
| 9 | 10 | gl_objects/groups | |
| 10 | 11 | gl_objects/projects | |
| 11 | 12 | gl_objects/runners | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,50 @@ | |||
| 1 | + # list | ||
| 2 | + commits = gl.project_commits.list(project_id=1) | ||
| 3 | + # or | ||
| 4 | + commits = project.commits.list() | ||
| 5 | + # end list | ||
| 6 | + | ||
| 7 | + # filter list | ||
| 8 | + commits = project.commits.list(ref_name='my_branch') | ||
| 9 | + commits = project.commits.list(since='2016-01-01T00:00:00Z') | ||
| 10 | + # end filter list | ||
| 11 | + | ||
| 12 | + # get | ||
| 13 | + commit = gl.project_commits.get('e3d5a71b', project_id=1) | ||
| 14 | + # or | ||
| 15 | + commit = project.commits.get('e3d5a71b') | ||
| 16 | + # end get | ||
| 17 | + | ||
| 18 | + # diff | ||
| 19 | + diff = commit.diff() | ||
| 20 | + # end diff | ||
| 21 | + | ||
| 22 | + # comments list | ||
| 23 | + comments = gl.project_commit_comments.list(project_id=1, commit_id='master') | ||
| 24 | + # or | ||
| 25 | + comments = project.commit_comments.list(commit_id='a5fe4c8') | ||
| 26 | + # or | ||
| 27 | + comments = commit.comments.list() | ||
| 28 | + # end comments list | ||
| 29 | + | ||
| 30 | + # comments create | ||
| 31 | + # Global comment | ||
| 32 | + commit = commit.comments.create({'note': 'This is a nice comment'}) | ||
| 33 | + # Comment on a line in a file (on the new version of the file) | ||
| 34 | + commit = commit.comments.create({'note': 'This is another comment', | ||
| 35 | + 'line': 12, | ||
| 36 | + 'line_type': 'new', | ||
| 37 | + 'path': 'README.rst'}) | ||
| 38 | + # end comments create | ||
| 39 | + | ||
| 40 | + # statuses list | ||
| 41 | + statuses = gl.project_commit_statuses.list(project_id=1, commit_id='master') | ||
| 42 | + # or | ||
| 43 | + statuses = project.commit_statuses.list(commit_id='a5fe4c8') | ||
| 44 | + # or | ||
| 45 | + statuses = commit.statuses.list() | ||
| 46 | + # end statuses list | ||
| 47 | + | ||
| 48 | + # statuses set | ||
| 49 | + commit.statuses.create({'state': 'success'}) | ||
| 50 | + # end statuses set | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,87 @@ | |||
| 1 | + ####### | ||
| 2 | + Commits | ||
| 3 | + ####### | ||
| 4 | + | ||
| 5 | + Commits | ||
| 6 | + ======= | ||
| 7 | + | ||
| 8 | + Use :class:`~gitlab.objects.ProjectCommit` objects to manipulate commits. The | ||
| 9 | + :attr:`gitlab.Gitlab.project_commits` and | ||
| 10 | + :attr:`gitlab.objects.Project.commits` manager objects provide helper | ||
| 11 | + functions. | ||
| 12 | + | ||
| 13 | + Examples | ||
| 14 | + -------- | ||
| 15 | + | ||
| 16 | + List the commits for a project: | ||
| 17 | + | ||
| 18 | + .. literalinclude:: commits.py | ||
| 19 | + :start-after: # list | ||
| 20 | + :end-before: # end list | ||
| 21 | + | ||
| 22 | + You can use the ``ref_name``, ``since`` and ``until`` filters to limit the | ||
| 23 | + results: | ||
| 24 | + | ||
| 25 | + .. literalinclude:: commits.py | ||
| 26 | + :start-after: # filter list | ||
| 27 | + :end-before: # end filter list | ||
| 28 | + | ||
| 29 | + Get a commit detail: | ||
| 30 | + | ||
| 31 | + .. literalinclude:: commits.py | ||
| 32 | + :start-after: # get | ||
| 33 | + :end-before: # end get | ||
| 34 | + | ||
| 35 | + Get the diff for a commit: | ||
| 36 | + | ||
| 37 | + .. literalinclude:: commits.py | ||
| 38 | + :start-after: # diff | ||
| 39 | + :end-before: # end diff | ||
| 40 | + | ||
| 41 | + Commit comments | ||
| 42 | + =============== | ||
| 43 | + | ||
| 44 | + Use :class:`~gitlab.objects.ProjectCommitStatus` objects to manipulate commits. The | ||
| 45 | + :attr:`gitlab.Gitlab.project_commit_comments` and | ||
| 46 | + :attr:`gitlab.objects.Project.commit_comments` and | ||
| 47 | + :attr:`gitlab.objects.ProjectCommit.comments` manager objects provide helper | ||
| 48 | + functions. | ||
| 49 | + | ||
| 50 | + Examples | ||
| 51 | + -------- | ||
| 52 | + | ||
| 53 | + Get the comments for a commit: | ||
| 54 | + | ||
| 55 | + .. literalinclude:: commits.py | ||
| 56 | + :start-after: # comments list | ||
| 57 | + :end-before: # end comments list | ||
| 58 | + | ||
| 59 | + Add a comment on a commit: | ||
| 60 | + | ||
| 61 | + .. literalinclude:: commits.py | ||
| 62 | + :start-after: # comments create | ||
| 63 | + :end-before: # end comments create | ||
| 64 | + | ||
| 65 | + Commit status | ||
| 66 | + ============= | ||
| 67 | + | ||
| 68 | + Use :class:`~gitlab.objects.ProjectCommitStatus` objects to manipulate commits. | ||
| 69 | + The :attr:`gitlab.Gitlab.project_commit_statuses`, | ||
| 70 | + :attr:`gitlab.objects.Project.commit_statuses` and | ||
| 71 | + :attr:`gitlab.objects.ProjectCommit.statuses` manager objects provide helper | ||
| 72 | + functions. | ||
| 73 | + | ||
| 74 | + Examples | ||
| 75 | + -------- | ||
| 76 | + | ||
| 77 | + Get the statuses for a commit: | ||
| 78 | + | ||
| 79 | + .. literalinclude:: commits.py | ||
| 80 | + :start-after: # statuses list | ||
| 81 | + :end-before: # end statuses list | ||
| 82 | + | ||
| 83 | + Change the status of a commit: | ||
| 84 | + | ||
| 85 | + .. literalinclude:: commits.py | ||
| 86 | + :start-after: # statuses set | ||
| 87 | + :end-before: # end statuses set | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments