X Tutup
Skip to content

Commit d11a9f2

Browse files
authored
Merge pull request #1 from python-gitlab/master
Sync up main project
2 parents 35cc8c7 + 7843ace commit d11a9f2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1303
-283
lines changed

.gitlab-ci.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ image: python:3.7
22

33
stages:
44
- deploy
5+
- deploy-latest
56

67
deploy:
78
stage: deploy
@@ -28,3 +29,14 @@ deploy_image:
2829
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
2930
only:
3031
- tags
32+
33+
deploy-latest:
34+
stage: deploy-latest
35+
image:
36+
name: gcr.io/go-containerregistry/crane:debug
37+
entrypoint: [""]
38+
script:
39+
- mkdir /root/.docker && echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /root/.docker/config.json
40+
- /ko-app/crane cp $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG $CI_REGISTRY_IMAGE:latest
41+
only:
42+
- tags

.travis.yml

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,49 +21,31 @@ jobs:
2121
- stage: lint
2222
name: black_lint
2323
dist: bionic
24-
python: 3.7
24+
python: 3.8
2525
script:
26-
- pip3 install black
26+
- pip3 install -U --pre black
2727
- black --check .
2828
- stage: test
2929
name: cli_func_v4
3030
dist: bionic
31-
python: 3.7
31+
python: 3.8
3232
script:
3333
- pip3 install tox
3434
- tox -e cli_func_v4
3535
- stage: test
3636
name: py_func_v4
3737
dist: bionic
38-
python: 3.7
38+
python: 3.8
3939
script:
4040
- pip3 install tox
4141
- tox -e py_func_v4
4242
- stage: test
4343
name: docs
4444
dist: bionic
45-
python: 3.7
45+
python: 3.8
4646
script:
4747
- pip3 install tox
4848
- tox -e docs
49-
- stage: test
50-
name: py27
51-
python: 2.7
52-
script:
53-
- pip2 install tox
54-
- tox -e py27
55-
- stage: test
56-
name: py34
57-
python: 3.4
58-
script:
59-
- pip3 install tox
60-
- tox -e py34
61-
- stage: test
62-
name: py35
63-
python: 3.5
64-
script:
65-
- pip3 install tox
66-
- tox -e py35
6749
- stage: test
6850
name: py36
6951
python: 3.6
@@ -81,7 +63,7 @@ jobs:
8163
- stage: test
8264
dist: bionic
8365
name: py38
84-
python: 3.8-dev
66+
python: 3.8
8567
script:
8668
- pip3 install tox
8769
- tox -e py38

ChangeLog.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
ChangeLog
2-
=========
1+
ChangeLog - Moved to GitHub releases
2+
====================================
3+
4+
The changes of newer versions can be found at https://github.com/python-gitlab/python-gitlab/releases
35

46
Version 1.9.0_ - 2019-06-19
57
---------------------------

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
FROM python:3.7-alpine AS build
1+
FROM python:3.8-alpine AS build
22

33
WORKDIR /opt/python-gitlab
44
COPY . .
55
RUN python setup.py bdist_wheel
66

7-
FROM python:3.7-alpine
7+
FROM python:3.8-alpine
88

99
WORKDIR /opt/python-gitlab
1010
COPY --from=build /opt/python-gitlab/dist dist/

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ include COPYING AUTHORS ChangeLog.rst RELEASE_NOTES.rst requirements.txt test-re
22
include tox.ini .testr.conf .travis.yml
33
recursive-include tools *
44
recursive-include docs *j2 *.py *.rst api/*.rst Makefile make.bat
5+
recursive-include gitlab/tests/data *

README.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ Requirements
3232
python-gitlab depends on:
3333

3434
* `python-requests <http://docs.python-requests.org/en/latest/>`_
35-
* `six <https://six.readthedocs.io/>`_
3635

3736
Install with pip
3837
----------------
@@ -57,7 +56,7 @@ How to use
5756

5857
or run it directly from the upstream image:
5958

60-
``docker run -it --rm -e GITLAB_PRIVATE_TOKEN=<your token> -v /path/to/python-gitlab.cfg:/python-gitlab.cfg registry.gitlab.com/python-gitlab/python-gitlab:v1.8.0 <command> ...``
59+
``docker run -it --rm -e GITLAB_PRIVATE_TOKEN=<your token> -v /path/to/python-gitlab.cfg:/python-gitlab.cfg registry.gitlab.com/python-gitlab/python-gitlab:latest <command> ...``
6160

6261
To change the GitLab URL, use `-e GITLAB_URL=<your url>`
6362

docs/api-objects.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ API examples
66
:maxdepth: 1
77

88
gl_objects/access_requests
9+
gl_objects/appearance
910
gl_objects/emojis
1011
gl_objects/badges
1112
gl_objects/branches
13+
gl_objects/clusters
1214
gl_objects/messages
1315
gl_objects/commits
1416
gl_objects/deploy_keys

docs/api-usage.rst

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ To connect to a GitLab server, create a ``gitlab.Gitlab`` object:
2323
import os
2424
gl = gitlab.Gitlab('http://10.0.0.1', job_token=os.environ['CI_JOB_TOKEN'])
2525
26-
# username/password authentication (for GitLab << 10.2)
27-
gl = gitlab.Gitlab('http://10.0.0.1', email='jdoe', password='s3cr3t')
28-
2926
# anonymous gitlab instance, read-only for public resources
3027
gl = gitlab.Gitlab('http://10.0.0.1')
3128
@@ -219,6 +216,18 @@ You can define the ``per_page`` value globally to avoid passing it to every
219216
220217
gl = gitlab.Gitlab(url, token, per_page=50)
221218
219+
Gitlab allows to also use keyset pagination. You can supply it to your project listing,
220+
but you can also do so globally. Be aware that GitLab then also requires you to only use supported
221+
order options. At the time of writing, only ``order_by="id"`` works.
222+
223+
.. code-block:: python
224+
225+
gl = gitlab.Gitlab(url, token, pagination="keyset", order_by="id", per_page=100)
226+
gl.projects.list()
227+
228+
Reference:
229+
https://docs.gitlab.com/ce/api/README.html#keyset-based-pagination
230+
222231
``list()`` methods can also return a generator object which will handle the
223232
next calls to the API when required. This is the recommended way to iterate
224233
through a large number of items:
@@ -348,3 +357,38 @@ throttled, you can set this parameter to -1. This parameter is ignored if
348357
.. warning::
349358

350359
You will get an Exception, if you then go over the rate limit of your GitLab instance.
360+
361+
Transient errors
362+
----------------
363+
364+
GitLab server can sometimes return a transient HTTP error.
365+
python-gitlab can automatically retry in such case, when
366+
``retry_transient_errors`` argument is set to ``True``. When enabled,
367+
HTTP error codes 500 (Internal Server Error), 502 (502 Bad Gateway),
368+
503 (Service Unavailable), and 504 (Gateway Timeout) are retried. By
369+
default an exception is raised for these errors.
370+
371+
.. code-block:: python
372+
373+
import gitlab
374+
import requests
375+
376+
gl = gitlab.gitlab(url, token, api_version=4)
377+
gl.projects.list(all=True, retry_transient_errors=True)
378+
379+
Timeout
380+
-------
381+
382+
python-gitlab will by default use the ``timeout`` option from it's configuration
383+
for all requests. This is passed downwards to the ``requests`` module at the
384+
time of making the HTTP request. However if you would like to override the
385+
global timeout parameter for a particular call, you can provide the ``timeout``
386+
parameter to that API invocation:
387+
388+
.. code-block:: python
389+
390+
import gitlab
391+
392+
gl = gitlab.gitlab(url, token, api_version=4)
393+
gl.projects.import_github(ACCESS_TOKEN, 123456, "root", timeout=120.0)
394+

docs/cli.rst

Lines changed: 63 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ example:
4141
[somewhere]
4242
url = https://some.whe.re
4343
private_token = vTbFeqJYCY3sibBP7BZM
44-
api_version = 3
44+
api_version = 4
4545
4646
[elsewhere]
4747
url = http://else.whe.re:8080
@@ -69,8 +69,8 @@ parameters. You can override the values in each GitLab server section.
6969
- Integer
7070
- Number of seconds to wait for an answer before failing.
7171
* - ``api_version``
72-
- ``3`` or ``4``
73-
- The API version to use to make queries. Requires python-gitlab >= 1.3.0.
72+
- ``4``
73+
- The API version to use to make queries. Only ``4`` is available since 1.5.0.
7474
* - ``per_page``
7575
- Integer between 1 and 100
7676
- The number of items to return in listing queries. GitLab limits the
@@ -103,8 +103,7 @@ server, with very limited permissions.
103103
* - ``job_token``
104104
- Your job token. See `the official documentation`_job-token to learn how to obtain a token.
105105
* - ``api_version``
106-
- GitLab API version to use (``3`` or ``4``). Defaults to ``4`` since
107-
version 1.3.0.
106+
- GitLab API version to use. Only ``4`` is available since 1.5.0.
108107
* - ``http_username``
109108
- Username for optional HTTP authentication
110109
* - ``http_password``
@@ -163,7 +162,7 @@ These options must be defined before the mandatory arguments.
163162
**Notice:**
164163

165164
The `PyYAML package <https://pypi.org/project/PyYAML/>`_ is required to use the yaml output option.
166-
You need to install it separately using ``pip install PyYAML``
165+
You need to install it explicitly using ``pip install python-gitlab[yaml]``
167166

168167
``--fields``, ``-f``
169168
Comma-separated list of fields to display (``yaml`` and ``json`` output
@@ -272,3 +271,61 @@ command line. This is handy for values containing new lines for instance:
272271
It is obviously the best project around
273272
EOF
274273
$ gitlab project create --name SuperProject --description @/tmp/description
274+
275+
Enabling shell autocompletion
276+
============================
277+
278+
To get autocompletion, you'll need to install the package with the extra
279+
"autocompletion":
280+
281+
.. code-block:: console
282+
283+
pip install python_gitlab[autocompletion]
284+
285+
286+
Add the appropriate command below to your shell's config file so that it is run on
287+
startup. You will likely have to restart or re-login for the autocompletion to
288+
start working.
289+
290+
Bash
291+
----
292+
293+
.. code-block:: console
294+
295+
eval "$(register-python-argcomplete gitlab)"
296+
297+
tcsh
298+
----
299+
300+
.. code-block:: console
301+
302+
eval `register-python-argcomplete --shell tcsh gitlab`
303+
304+
fish
305+
----
306+
307+
.. code-block:: console
308+
309+
register-python-argcomplete --shell fish gitlab | .
310+
311+
Zsh
312+
---
313+
314+
.. warning::
315+
316+
Zsh autocompletion support is broken right now in the argcomplete python
317+
package. Perhaps it will be fixed in a future release of argcomplete at
318+
which point the following instructions will enable autocompletion in zsh.
319+
320+
To activate completions for zsh you need to have bashcompinit enabled in zsh:
321+
322+
.. code-block:: console
323+
324+
autoload -U bashcompinit
325+
bashcompinit
326+
327+
Afterwards you can enable completion for gitlab:
328+
329+
.. code-block:: console
330+
331+
eval "$(register-python-argcomplete gitlab)"

docs/ext/docstrings.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import os
44

55
import jinja2
6-
import six
76
import sphinx
87
import sphinx.ext.napoleon as napoleon
98
from sphinx.ext.napoleon.docstring import GoogleDocstring
@@ -25,7 +24,7 @@ def setup(app):
2524

2625
conf = napoleon.Config._config_values
2726

28-
for name, (default, rebuild) in six.iteritems(conf):
27+
for name, (default, rebuild) in conf.items():
2928
app.add_config_value(name, default, rebuild)
3029
return {"version": sphinx.__display_version__, "parallel_read_safe": True}
3130

0 commit comments

Comments
 (0)
X Tutup