与gitlab api交互

python-gitlab的Python项目详细描述


https://travis-ci.org/python-gitlab/python-gitlab.svg?branch=masterhttps://badge.fury.io/py/python-gitlab.svghttps://readthedocs.org/projects/python-gitlab/badge/?version=latesthttps://img.shields.io/pypi/pyversions/python-gitlab.svghttps://img.shields.io/gitter/room/python-gitlab/Lobby.svghttps://img.shields.io/badge/code%20style-black-000000.svg

python gitlab

python-gitlab是一个python包,提供对gitlab服务器api的访问。

它支持gitlab的v4 api,并提供一个cli工具(gitlab)。

安装

要求

python gitlab依赖于:

使用pip

安装
pip install python-gitlab

使用python gitlab docker图像

如何构建

docker build -tpython-gitlab:TAG .

如何使用

docker run -it--rm-eGITLAB_PRIVATE_TOKEN=<your token> -v/path/to/python-gitlab.cfg:/python-gitlab.cfgpython-gitlab <command> ...

或者直接从上游图像运行:

docker run -it--rm-eGITLAB_PRIVATE_TOKEN=<your token> -v/path/to/python-gitlab.cfg:/python-gitlab.cfgregistry.gitlab.com/python-gitlab/python-gitlab:v1.8.0 <command> ...

要更改gitlab url,请使用-e gitlab_url=<;您的url>;

自带配置文件: docker run -it--rm-v/path/to/python-gitlab.cfg:/python-gitlab.cfg-eGITLAB_CFG=/python-gitlab.cfgpython-gitlab <command> ...

错误报告

请在报告错误和功能请求 https://github.com/python-gitlab/python-gitlab/issues

文档

cli和api的完整文档可在readthedocs上找到。

创建文档

您可以使用sphinx

pip install sphinx
python setup.py build_sphinx

贡献

您可以通过多种方式为项目做出贡献:

  • 编写文档
  • 实现功能
  • 修复错误
  • 添加单元和功能测试
  • 你能想到的一切

我们强制使用conventional-changelog格式化提交消息。 这将导致在查看项目历史记录时更易于理解的消息。

请按照github pull请求提供修补程序。谢谢!

代码样式

我们使用黑色作为代码格式化程序,因此您需要使用 black code formatter

只需运行

cd python-gitlab/
pip3 install --user black
black .

根据我们的指导来格式化你的代码。

运行单元测试

在提交pull请求之前,请确保测试仍然成功 你的零钱。单元测试和功能测试使用travis服务和 必须通过测试才能接受合并请求。

您需要安装tox才能在本地运行单元测试和文档生成:

# run the unit tests for python 2/3, and the pep8 tests:
tox

# run tests in one environment only:
tox -epy35

# build the documentation, the result will be generated in
# build/sphinx/html/
tox -edocs

运行集成测试

两个脚本使用docker对正在运行的gitlab实例运行测试 集装箱。你需要在测试机器上安装Docker,你的用户 必须具有与Docker守护进程对话的正确权限。

要运行这些测试:

# run the CLI tests:
./tools/functional_tests.sh

# run the python API tests:
./tools/py_functional_tests.sh

还可以使用以下命令构建测试环境:

./tools/build_test_env.sh

新配置的gitlab容器将在 http://localhost:8080(登录root/密码5iveL!fe)。配置 对于python,gitlab将用/tmp/python-gitlab.cfg编写。

要清除环境,请删除容器:

docker rm -f gitlab-test

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java Clojure关键字在内存中的大小是多少?   Java中有固定长度的通用数组对象吗?   PostgreSQL:通过Java更新我的用户表   错误:使用java解析xml   java Json显示列表中对象的名称   java比较JodaTime时区   与JAVA中的API和包的区别?   java的int值在for循环中不改变   谷歌应用引擎中的java RSA   迁移到spring 5后出现java非法字符错误   java Websphere管理控制台不工作   JavaGSON如何始终在json中包含毫秒?   带有空格和双引号的windows Java ProcessBuilder命令参数失败   java错误:重复的zip条目[43.jar:org/apache/http/annotation/NotThreadSafe.class]