summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/docs.yml39
-rw-r--r--.github/workflows/lint.yml23
-rw-r--r--.github/workflows/test.yml71
-rw-r--r--.renovaterc.json2
-rw-r--r--.travis.yml108
-rw-r--r--docker-requirements.txt1
-rw-r--r--docs/gl_objects/groups.rst4
-rw-r--r--gitlab/__init__.py14
-rw-r--r--gitlab/const.py1
-rw-r--r--gitlab/v4/objects/__init__.py8
-rw-r--r--requirements.txt3
-rw-r--r--setup.py2
-rw-r--r--tools/functional/api/test_projects.py7
-rw-r--r--tools/functional/fixtures/.env (renamed from .env)2
14 files changed, 161 insertions, 124 deletions
diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml
new file mode 100644
index 0000000..04f47b6
--- /dev/null
+++ b/.github/workflows/docs.yml
@@ -0,0 +1,39 @@
+name: Docs
+
+on: [push, pull_request]
+
+env:
+ PY_COLORS: 1
+
+jobs:
+ sphinx:
+ runs-on: ubuntu-20.04
+ steps:
+ - uses: actions/checkout@v2
+ - name: Set up Python
+ uses: actions/setup-python@v2
+ with:
+ python-version: 3.8
+ - name: Install dependencies
+ run: pip install tox
+ - name: Build docs
+ env:
+ TOXENV: docs
+ run: tox
+
+ twine-check:
+ runs-on: ubuntu-20.04
+ steps:
+ - uses: actions/checkout@v2
+ - name: Set up Python
+ uses: actions/setup-python@v2
+ with:
+ python-version: 3.8
+ - name: Install dependencies
+ run: pip install tox twine wheel
+ - name: Check twine readme rendering
+ env:
+ TOXENV: twine-check
+ run: |
+ python3 setup.py sdist bdist_wheel
+ tox
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
new file mode 100644
index 0000000..535fa01
--- /dev/null
+++ b/.github/workflows/lint.yml
@@ -0,0 +1,23 @@
+name: Lint
+
+on: [push, pull_request]
+
+env:
+ PY_COLORS: 1
+
+jobs:
+ black:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - uses: actions/setup-python@v2
+ - uses: psf/black@stable
+ with:
+ black_args: ". --check"
+ commitlint:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ with:
+ fetch-depth: 0
+ - uses: wagoid/commitlint-github-action@v2
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
new file mode 100644
index 0000000..44708d3
--- /dev/null
+++ b/.github/workflows/test.yml
@@ -0,0 +1,71 @@
+name: Test
+
+on: [push, pull_request]
+
+env:
+ PY_COLORS: 1
+
+jobs:
+ unit:
+ runs-on: ubuntu-20.04
+ strategy:
+ matrix:
+ include:
+ - python-version: 3.6
+ toxenv: py36
+ - python-version: 3.7
+ toxenv: py37
+ - python-version: 3.8
+ toxenv: py38
+ steps:
+ - uses: actions/checkout@v2
+ - name: Set up Python ${{ matrix.python-version }}
+ uses: actions/setup-python@v2
+ with:
+ python-version: ${{ matrix.python-version }}
+ - name: Install dependencies
+ run: pip install tox pytest-github-actions-annotate-failures
+ - name: Run tests
+ env:
+ TOXENV: ${{ matrix.toxenv }}
+ run: tox
+
+ functional:
+ runs-on: ubuntu-20.04
+ strategy:
+ matrix:
+ toxenv: [py_func_v4, cli_func_v4]
+ steps:
+ - uses: actions/checkout@v2
+ - name: Set up Python
+ uses: actions/setup-python@v2
+ with:
+ python-version: 3.8
+ - name: Install dependencies
+ run: pip install tox pytest-github-actions-annotate-failures
+ - name: Run tests
+ env:
+ TOXENV: ${{ matrix.toxenv }}
+ run: tox
+
+ coverage:
+ runs-on: ubuntu-20.04
+ steps:
+ - uses: actions/checkout@v2
+ - name: Set up Python ${{ matrix.python-version }}
+ uses: actions/setup-python@v2
+ with:
+ python-version: 3.8
+ - name: Install dependencies
+ run: pip install tox pytest-github-actions-annotate-failures
+ - name: Run tests
+ env:
+ PY_COLORS: 1
+ TOXENV: cover
+ run: tox
+ - name: Upload codecov coverage
+ uses: codecov/codecov-action@v1
+ with:
+ files: ./coverage.xml
+ flags: unit
+ fail_ci_if_error: true
diff --git a/.renovaterc.json b/.renovaterc.json
index 037a97e..b46c8f4 100644
--- a/.renovaterc.json
+++ b/.renovaterc.json
@@ -4,7 +4,7 @@
],
"regexManagers": [
{
- "fileMatch": ["^.env$"],
+ "fileMatch": ["^tools/functional/fixtures/.env$"],
"matchStrings": ["GITLAB_TAG=(?<currentValue>.*?)\n"],
"depNameTemplate": "gitlab/gitlab-ce",
"datasourceTemplate": "docker",
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 09359b5..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,108 +0,0 @@
-sudo: required
-services:
- - docker
-language: python
-
-git:
- depth: false
-
-stages:
- - lint
- - test
-
-jobs:
- include:
- - stage: lint
- name: commitlint
- python: 3.8
- script:
- - pip3 install pre-commit
- - pre-commit run --hook-stage manual commitlint-travis
- cache:
- directories:
- - $HOME/.cache/pre-commit
- - stage: lint
- name: black_lint
- dist: bionic
- python: 3.8
- script:
- - pip3 install -U --pre black==20.8b1
- - black --check .
- - stage: test
- name: cli_func_v4
- dist: bionic
- python: 3.8
- script:
- - pip3 install tox
- - tox -e cli_func_v4
- - stage: test
- name: py_func_v4
- dist: bionic
- python: 3.8
- script:
- - pip3 install tox
- - tox -e py_func_v4
- - stage: test
- name: cli_func_nightly
- dist: bionic
- python: 3.8
- env: GITLAB_TAG=nightly
- script:
- - pip3 install tox
- - tox -e cli_func_v4
- - stage: test
- name: py_func_nightly
- dist: bionic
- python: 3.8
- env: GITLAB_TAG=nightly
- script:
- - pip3 install tox
- - tox -e py_func_v4
- - stage: test
- name: docs
- dist: bionic
- python: 3.8
- script:
- - pip3 install tox
- - tox -e docs
- - stage: test
- name: py36
- python: 3.6
- dist: bionic
- script:
- - pip3 install tox
- - tox -e py36
- - stage: test
- name: py37
- dist: bionic
- python: 3.7
- script:
- - pip3 install tox
- - tox -e py37
- - stage: test
- dist: bionic
- name: py38
- python: 3.8
- script:
- - pip3 install tox
- - tox -e py38
- - stage: test
- dist: bionic
- name: twine-check
- python: 3.8
- script:
- - pip3 install tox wheel
- - python3 setup.py sdist bdist_wheel
- - tox -e twine-check
- - stage: test
- dist: bionic
- name: coverage
- python: 3.8
- install:
- - pip3 install tox codecov
- script:
- - tox -e cover
- after_success:
- - codecov
- allow_failures:
- - env: GITLAB_TAG=nightly
diff --git a/docker-requirements.txt b/docker-requirements.txt
index 1bcd74b..b7a3333 100644
--- a/docker-requirements.txt
+++ b/docker-requirements.txt
@@ -1,4 +1,5 @@
-r requirements.txt
-r test-requirements.txt
+docker-compose==1.28.2 # prevent inconsistent .env behavior from system install
pytest-console-scripts
pytest-docker
diff --git a/docs/gl_objects/groups.rst b/docs/gl_objects/groups.rst
index 199847d..1880a6b 100644
--- a/docs/gl_objects/groups.rst
+++ b/docs/gl_objects/groups.rst
@@ -56,6 +56,10 @@ Create a group::
group = gl.groups.create({'name': 'group1', 'path': 'group1'})
+Create a subgroup under an existing group::
+
+ subgroup = gl.groups.create({'name': 'subgroup1', 'path': 'subgroup1', 'parent_id': parent_group_id})
+
Update a group::
group.description = 'My awesome group'
diff --git a/gitlab/__init__.py b/gitlab/__init__.py
index 960f086..98c4144 100644
--- a/gitlab/__init__.py
+++ b/gitlab/__init__.py
@@ -27,9 +27,11 @@ import gitlab.config
from gitlab.const import * # noqa
from gitlab.exceptions import * # noqa
from gitlab import utils # noqa
+from requests_toolbelt.multipart.encoder import MultipartEncoder
+
__title__ = "python-gitlab"
-__version__ = "2.5.0"
+__version__ = "2.6.0"
__author__ = "Gauvain Pocentek"
__email__ = "gauvainpocentek@gmail.com"
__license__ = "LGPL3"
@@ -496,9 +498,11 @@ class Gitlab(object):
# We need to deal with json vs. data when uploading files
if files:
- data = post_data
json = None
- del opts["headers"]["Content-type"]
+ post_data["file"] = files.get("file")
+ post_data["avatar"] = files.get("avatar")
+ data = MultipartEncoder(post_data)
+ opts["headers"]["Content-type"] = data.content_type
else:
json = post_data
data = None
@@ -509,9 +513,7 @@ class Gitlab(object):
# The Requests behavior is right but it seems that web servers don't
# always agree with this decision (this is the case with a default
# gitlab installation)
- req = requests.Request(
- verb, url, json=json, data=data, params=params, files=files, **opts
- )
+ req = requests.Request(verb, url, json=json, data=data, params=params, **opts)
prepped = self.session.prepare_request(req)
prepped.url = utils.sanitized_url(prepped.url)
settings = self.session.merge_environment_settings(
diff --git a/gitlab/const.py b/gitlab/const.py
index 0d2f421..bdd3d73 100644
--- a/gitlab/const.py
+++ b/gitlab/const.py
@@ -16,6 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
NO_ACCESS = 0
+MINIMAL_ACCESS = 5
GUEST_ACCESS = 10
REPORTER_ACCESS = 20
DEVELOPER_ACCESS = 30
diff --git a/gitlab/v4/objects/__init__.py b/gitlab/v4/objects/__init__.py
index edeff04..6184440 100644
--- a/gitlab/v4/objects/__init__.py
+++ b/gitlab/v4/objects/__init__.py
@@ -1615,7 +1615,7 @@ class GroupManager(CRUDMixin, RESTManager):
Returns:
dict: A representation of the import status.
"""
- files = {"file": ("file.tar.gz", file)}
+ files = {"file": ("file.tar.gz", file, "application/octet-stream")}
data = {"path": path, "name": name}
if parent_id is not None:
data["parent_id"] = parent_id
@@ -3601,7 +3601,7 @@ class ProjectLabel(SubscribableMixin, SaveMixin, ObjectDeleteMixin, RESTObject):
class ProjectLabelManager(
- ListMixin, CreateMixin, UpdateMixin, DeleteMixin, RESTManager
+ RetrieveMixin, CreateMixin, UpdateMixin, DeleteMixin, RESTManager
):
_path = "/projects/%(project_id)s/labels"
_obj_cls = ProjectLabel
@@ -5488,8 +5488,8 @@ class ProjectManager(CRUDMixin, RESTManager):
Returns:
dict: A representation of the import status.
"""
- files = {"file": ("file.tar.gz", file)}
- data = {"path": path, "overwrite": overwrite}
+ files = {"file": ("file.tar.gz", file, "application/octet-stream")}
+ data = {"path": path, "overwrite": str(overwrite)}
if override_params:
for k, v in override_params.items():
data["override_params[%s]" % k] = v
diff --git a/requirements.txt b/requirements.txt
index 989b995..b2c3e43 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1 +1,2 @@
-requests==2.24.0
+requests==2.25.1
+requests-toolbelt==0.9.1
diff --git a/setup.py b/setup.py
index 9626083..935ebae 100644
--- a/setup.py
+++ b/setup.py
@@ -26,7 +26,7 @@ setup(
license="LGPLv3",
url="https://github.com/python-gitlab/python-gitlab",
packages=find_packages(),
- install_requires=["requests>=2.22.0"],
+ install_requires=["requests>=2.22.0", "requests-toolbelt>=0.9.1"],
python_requires=">=3.6.0",
entry_points={"console_scripts": ["gitlab = gitlab.cli:main"]},
classifiers=[
diff --git a/tools/functional/api/test_projects.py b/tools/functional/api/test_projects.py
index 3e88c0c..945a6ec 100644
--- a/tools/functional/api/test_projects.py
+++ b/tools/functional/api/test_projects.py
@@ -139,8 +139,11 @@ def test_project_housekeeping(project):
def test_project_labels(project):
label = project.labels.create({"name": "label", "color": "#778899"})
- label = project.labels.list()[0]
- assert len(project.labels.list()) == 1
+ labels = project.labels.list()
+ assert len(labels) == 1
+
+ label = project.labels.get("label")
+ assert label == labels[0]
label.new_name = "labelupdated"
label.save()
diff --git a/.env b/tools/functional/fixtures/.env
index ada8b49..bffdba0 100644
--- a/.env
+++ b/tools/functional/fixtures/.env
@@ -1,2 +1,2 @@
GITLAB_IMAGE=gitlab/gitlab-ce
-GITLAB_TAG=13.5.4-ce.0
+GITLAB_TAG=13.8.1-ce.0