2016-01-02 18:07:00 +01:00
|
|
|
|
######################
|
2014-04-24 18:20:23 +02:00
|
|
|
|
Contributing to HTTPie
|
|
|
|
|
######################
|
|
|
|
|
|
2016-01-02 18:07:00 +01:00
|
|
|
|
Bug reports and code and documentation patches are welcome. You can
|
|
|
|
|
help this project also by using the development version of HTTPie
|
|
|
|
|
and by reporting any bugs you might encounter.
|
2014-04-24 18:20:23 +02:00
|
|
|
|
|
2016-01-02 18:07:00 +01:00
|
|
|
|
1. Reporting bugs
|
|
|
|
|
=================
|
2014-04-24 18:20:23 +02:00
|
|
|
|
|
2014-05-09 13:48:34 +02:00
|
|
|
|
**It's important that you provide the full command argument list
|
|
|
|
|
as well as the output of the failing command.**
|
2014-05-09 13:46:33 +02:00
|
|
|
|
Use the ``--debug`` flag and copy&paste both the command and its output
|
|
|
|
|
to your bug report, e.g.:
|
2014-04-24 18:20:23 +02:00
|
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
2020-06-26 17:48:04 +02:00
|
|
|
|
$ http --debug <COMPLETE ARGUMENT LIST THAT TRIGGERS THE ERROR>
|
|
|
|
|
|
|
|
|
|
<COMPLETE OUTPUT>
|
2014-04-24 18:20:23 +02:00
|
|
|
|
|
|
|
|
|
|
2016-01-02 18:07:00 +01:00
|
|
|
|
2. Contributing Code and Docs
|
|
|
|
|
=============================
|
2014-04-24 18:20:23 +02:00
|
|
|
|
|
|
|
|
|
Before working on a new feature or a bug, please browse `existing issues`_
|
2020-06-26 17:48:04 +02:00
|
|
|
|
to see whether it has previously been discussed.
|
|
|
|
|
|
|
|
|
|
If your change alters HTTPie’s behaviour or interface, it's a good idea to
|
|
|
|
|
discuss it before you start working on it.
|
|
|
|
|
|
|
|
|
|
If you are fixing an issue, the first step should be to create a test case that
|
|
|
|
|
reproduces the incorrect behaviour. That will also help you to build an
|
|
|
|
|
understanding of the issue at hand.
|
|
|
|
|
|
2020-07-07 13:19:42 +02:00
|
|
|
|
**Pull requests introducing code changes without tests
|
2020-06-26 17:48:04 +02:00
|
|
|
|
will generally not get merged. The same goes for PRs changing HTTPie’s
|
2020-07-07 13:19:42 +02:00
|
|
|
|
behaviour and not providing documentation.**
|
2020-06-26 17:48:04 +02:00
|
|
|
|
|
|
|
|
|
Conversely, PRs consisting of documentation improvements or tests
|
|
|
|
|
for existing-yet-previously-untested behavior will very likely be merged.
|
|
|
|
|
Therefore, docs and tests improvements are a great candidate for your first
|
|
|
|
|
contribution.
|
|
|
|
|
|
|
|
|
|
Consider also adding a ``CHANGELOG`` entry for your changes.
|
2014-04-24 18:20:23 +02:00
|
|
|
|
|
|
|
|
|
|
2019-12-04 17:49:07 +01:00
|
|
|
|
Development Environment
|
2016-01-02 18:07:00 +01:00
|
|
|
|
--------------------------------
|
|
|
|
|
|
2019-12-04 17:49:07 +01:00
|
|
|
|
|
|
|
|
|
Getting the code
|
|
|
|
|
****************
|
|
|
|
|
|
2017-03-10 11:27:38 +01:00
|
|
|
|
Go to https://github.com/jakubroztocil/httpie and fork the project repository.
|
2016-01-02 18:07:00 +01:00
|
|
|
|
|
2014-04-24 18:20:23 +02:00
|
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
2019-12-04 17:49:07 +01:00
|
|
|
|
# Clone your fork
|
|
|
|
|
git clone git@github.com:<YOU>/httpie.git
|
2014-04-24 18:20:23 +02:00
|
|
|
|
|
2019-12-04 17:49:07 +01:00
|
|
|
|
# Enter the project directory
|
2014-04-24 18:20:23 +02:00
|
|
|
|
cd httpie
|
|
|
|
|
|
2019-12-04 17:49:07 +01:00
|
|
|
|
# Create a branch for your changes
|
2014-04-24 18:20:23 +02:00
|
|
|
|
git checkout -b my_topical_branch
|
|
|
|
|
|
|
|
|
|
|
2019-12-04 17:49:07 +01:00
|
|
|
|
Setup
|
|
|
|
|
*****
|
|
|
|
|
|
|
|
|
|
The `Makefile`_ contains a bunch of tasks to get you started. Just run
|
2019-12-04 18:34:26 +01:00
|
|
|
|
the following command, which:
|
2019-12-04 17:49:07 +01:00
|
|
|
|
|
|
|
|
|
|
2019-12-04 18:34:26 +01:00
|
|
|
|
* Creates an isolated Python virtual environment inside ``./venv``
|
2019-12-04 17:49:07 +01:00
|
|
|
|
(via the standard library `venv`_ tool);
|
|
|
|
|
* installs all dependencies and also installs HTTPie
|
|
|
|
|
(in editable mode so that the ``http`` command will point to your
|
|
|
|
|
working copy).
|
|
|
|
|
* and runs tests (It is the same as running ``make install test``).
|
|
|
|
|
|
|
|
|
|
|
2019-12-04 18:34:26 +01:00
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
|
|
make
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-12-04 17:49:07 +01:00
|
|
|
|
Python virtual environment
|
|
|
|
|
**************************
|
|
|
|
|
|
|
|
|
|
Activate the Python virtual environment—created via the ``make install``
|
|
|
|
|
task during `setup`_—for your active shell session using the following command:
|
|
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
|
|
source venv/bin/activate
|
|
|
|
|
|
|
|
|
|
(If you use ``virtualenvwrapper``, you can also use ``workon httpie`` to
|
2019-12-04 18:48:39 +01:00
|
|
|
|
activate the environment — we have created a symlink for you. It’s a bit of
|
2019-12-04 17:49:07 +01:00
|
|
|
|
a hack but it works™.)
|
|
|
|
|
|
|
|
|
|
You should now see ``(httpie)`` next to your shell prompt, and
|
2020-07-16 22:47:39 +02:00
|
|
|
|
the ``http`` command should point to your development copy:
|
2019-12-04 17:49:07 +01:00
|
|
|
|
|
|
|
|
|
.. code-block::
|
|
|
|
|
|
|
|
|
|
(httpie) ~/Code/httpie $ which http
|
|
|
|
|
/Users/jakub/Code/httpie/venv/bin/http
|
|
|
|
|
(httpie) ~/Code/httpie $ http --version
|
|
|
|
|
2.0.0-dev
|
|
|
|
|
|
|
|
|
|
(Btw, you don’t need to activate the virtual environment if you just want
|
|
|
|
|
run some of the ``make`` tasks. You can also invoke the development
|
|
|
|
|
version of HTTPie directly with ``./venv/bin/http`` without having to activate
|
|
|
|
|
the environment first. The same goes for ``./venv/bin/py.test``, etc.).
|
2014-04-24 18:20:23 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Making Changes
|
|
|
|
|
--------------
|
|
|
|
|
|
2018-07-12 21:16:16 +02:00
|
|
|
|
Please make sure your changes conform to `Style Guide for Python Code`_ (PEP8)
|
|
|
|
|
and that ``make pycodestyle`` passes.
|
2014-04-24 18:20:23 +02:00
|
|
|
|
|
|
|
|
|
|
2019-12-04 17:49:07 +01:00
|
|
|
|
Testing & CI
|
|
|
|
|
------------
|
2014-04-24 18:20:23 +02:00
|
|
|
|
|
2019-12-04 17:49:07 +01:00
|
|
|
|
Please add tests for any new features and bug fixes.
|
2014-04-24 18:20:23 +02:00
|
|
|
|
|
2019-12-04 17:49:07 +01:00
|
|
|
|
When you open a pull request,
|
2020-04-20 17:45:51 +02:00
|
|
|
|
`GitHub Actions <https://github.com/jakubroztocil/httpie/actions>`_
|
2019-12-04 17:49:07 +01:00
|
|
|
|
will automatically run HTTPie’s `test suite`_ against your code
|
|
|
|
|
so please make sure all checks pass.
|
2014-04-24 18:20:23 +02:00
|
|
|
|
|
|
|
|
|
|
2019-12-04 17:49:07 +01:00
|
|
|
|
Running tests locally
|
|
|
|
|
*********************
|
|
|
|
|
|
2020-06-26 17:22:06 +02:00
|
|
|
|
HTTPie uses the `pytest`_ runner.
|
2019-12-04 17:49:07 +01:00
|
|
|
|
|
2016-01-02 18:07:00 +01:00
|
|
|
|
|
|
|
|
|
.. code-block:: bash
|
2014-04-24 21:36:03 +02:00
|
|
|
|
|
2019-12-04 17:49:07 +01:00
|
|
|
|
# Run tests on the current Python interpreter with coverage.
|
2014-04-28 13:25:45 +02:00
|
|
|
|
make test
|
|
|
|
|
|
2019-12-04 17:49:07 +01:00
|
|
|
|
# Run tests with coverage
|
|
|
|
|
make test-cover
|
|
|
|
|
|
2018-07-12 21:16:16 +02:00
|
|
|
|
# Test PEP8 compliance
|
|
|
|
|
make pycodestyle
|
|
|
|
|
|
2019-12-04 17:49:07 +01:00
|
|
|
|
# Run extended tests — for code as well as .rst files syntax, packaging, etc.
|
|
|
|
|
make test-all
|
|
|
|
|
|
2014-04-24 21:36:03 +02:00
|
|
|
|
|
2019-12-04 17:49:07 +01:00
|
|
|
|
Running specific tests
|
|
|
|
|
**********************
|
|
|
|
|
|
|
|
|
|
After you have activated your virtual environment (see `setup`_), you
|
|
|
|
|
can run specific tests from the terminal:
|
2016-01-02 18:07:00 +01:00
|
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
|
|
# Run specific tests on the current Python
|
|
|
|
|
py.test tests/test_uploads.py
|
|
|
|
|
py.test tests/test_uploads.py::TestMultipartFormDataFileUpload
|
|
|
|
|
py.test tests/test_uploads.py::TestMultipartFormDataFileUpload::test_upload_ok
|
2014-04-24 18:20:23 +02:00
|
|
|
|
|
2016-01-02 18:07:00 +01:00
|
|
|
|
-----
|
2014-04-24 18:20:23 +02:00
|
|
|
|
|
2016-01-02 18:28:46 +01:00
|
|
|
|
See `Makefile`_ for additional development utilities.
|
2019-12-04 17:49:07 +01:00
|
|
|
|
|
2020-06-26 17:48:04 +02:00
|
|
|
|
Windows
|
|
|
|
|
*******
|
|
|
|
|
|
|
|
|
|
If you are on a Windows machine and not able to run ``make``,
|
|
|
|
|
follow the next steps for a basic setup. As a prerequisite, you need to have
|
|
|
|
|
Python 3.6+ installed.
|
|
|
|
|
|
|
|
|
|
Create a virtual environment and activate it:
|
|
|
|
|
|
|
|
|
|
.. code-block:: powershell
|
|
|
|
|
|
|
|
|
|
python -m venv --prompt httpie venv
|
|
|
|
|
venv\Scripts\activate
|
|
|
|
|
|
|
|
|
|
Install HTTPie in editable mode with all the dependencies:
|
|
|
|
|
|
|
|
|
|
.. code-block:: powershell
|
|
|
|
|
|
|
|
|
|
pip install --upgrade -e . -r requirements-dev.txt
|
|
|
|
|
|
|
|
|
|
You should now see ``(httpie)`` next to your shell prompt, and
|
2020-07-16 22:47:39 +02:00
|
|
|
|
the ``http`` command should point to your development copy:
|
2020-06-26 17:48:04 +02:00
|
|
|
|
|
|
|
|
|
.. code-block:: powershell
|
|
|
|
|
|
|
|
|
|
# In PowerShell:
|
|
|
|
|
(httpie) PS C:\Users\ovezovs\httpie> Get-Command http
|
|
|
|
|
CommandType Name Version Source
|
|
|
|
|
----------- ---- ------- ------
|
|
|
|
|
Application http.exe 0.0.0.0 C:\Users\ovezovs\httpie\venv\Scripts\http.exe
|
|
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
|
|
# In CMD:
|
|
|
|
|
(httpie) C:\Users\ovezovs\httpie> where http
|
|
|
|
|
C:\Users\ovezovs\httpie\venv\Scripts\http.exe
|
|
|
|
|
C:\Users\ovezovs\AppData\Local\Programs\Python\Python38-32\Scripts\http.exe
|
|
|
|
|
|
|
|
|
|
(httpie) C:\Users\ovezovs\httpie> http --version
|
|
|
|
|
2.3.0-dev
|
|
|
|
|
|
|
|
|
|
Use ``pytest`` to run tests locally with an active virtual environment:
|
|
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
|
|
# Run all tests
|
|
|
|
|
py.test
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-----
|
|
|
|
|
|
2019-12-04 17:49:07 +01:00
|
|
|
|
|
2020-06-26 17:48:04 +02:00
|
|
|
|
Finally, feel free to add yourself to `AUTHORS`_!
|
2014-04-24 18:20:23 +02:00
|
|
|
|
|
|
|
|
|
|
2017-03-10 11:27:38 +01:00
|
|
|
|
.. _existing issues: https://github.com/jakubroztocil/httpie/issues?state=open
|
|
|
|
|
.. _AUTHORS: https://github.com/jakubroztocil/httpie/blob/master/AUTHORS.rst
|
|
|
|
|
.. _Makefile: https://github.com/jakubroztocil/httpie/blob/master/Makefile
|
2019-12-04 17:49:07 +01:00
|
|
|
|
.. _venv: https://docs.python.org/3/library/venv.html
|
2019-08-30 10:07:01 +02:00
|
|
|
|
.. _pytest: https://pytest.org/
|
|
|
|
|
.. _Style Guide for Python Code: https://python.org/dev/peps/pep-0008/
|
2017-03-10 11:27:38 +01:00
|
|
|
|
.. _test suite: https://github.com/jakubroztocil/httpie/tree/master/tests
|