Code Monkey home page Code Monkey logo

git-pw's Introduction

git-pw

PyPi Status Documentation Status Build Status

git-pw is a tool for integrating Git with Patchwork, the web-based patch tracking system.

Important

git-pw only supports Patchwork 2.0+ and REST API support must be enabled on the server end. You can check for support by browsing /about for your given instance. If this page returns a 404, you are using Patchwork < 2.0.

The pwclient utility can be used to interact with older Patchwork instances or instances with the REST API disabled.

Installation

The easiest way to install git-pw and its dependencies is using pip. To do so, run:

$ pip install git-pw

You can also install git-pw manually. First, install the required dependencies. On Fedora, run:

$ sudo dnf install python3-requests python3-click python3-pbr \
    python3-arrow python3-tabulate python3-yaml

On Ubuntu, run:

$ sudo apt-get install python3-requests python3-click python3-pbr \
    python3-arrow python3-tabulate python3-yaml

Once dependencies are installed, clone this repo and run setup.py:

$ git clone https://github.com/getpatchwork/git-pw
$ cd git-pw
$ pip install --user .  # or 'sudo python setup.py install'

Getting Started

To begin, you'll need to configure Git settings appropriately. The following settings are required:

pw.server

The URL for the Patchwork instance's API. This should include the API version:

https://patchwork.ozlabs.org/api/1.2

You can discover the API version supported by your instance by comparing the server version, found at /about, with the API versions provided in the documentation. For example, if your server is running Patchwork version 3.0.x, you should use API version 1.2.

pw.project

The project name or list-id. This will appear in the URL when using the web UI:

https://patchwork.ozlabs.org/project/{project_name}/list/

For read-write access, you also need authentication - you can use either API tokens or a username/password combination:

pw.token
The API token for your Patchwork account.
pw.username
The username for your Patchwork account.
pw.password
The password for your Patchwork account.

If only read-only access is desired, credentials can be omitted.

The following settings are optional and may need to be set depending on your Patchwork instance's configuration:

pw.states
The states that can be applied to a patch using the git pw patch update command. Should be provided in slug form (changes-requested instead of Changes Requested). Only required if your Patchwork instance uses non-default states.

You can set these settings using the git config command. This should be done in the repo in which you intend to apply patches. For example, to configure the Patchwork project, run:

$ git config pw.server 'https://patchwork.ozlabs.org/api/1.1/'
$ git config pw.project 'patchwork'

Development

If you're interested in contributing to git-pw, first clone the repo:

$ git clone https://github.com/getpatchwork/git-pw
$ cd git-pw

Create a virtualenv, then install the package in editable mode:

$ virtualenv .venv
$ source .venv/bin/activate
$ pip install --editable .

Documentation

Documentation is available on Read the Docs

git-pw's People

Contributors

00-matt avatar apconole avatar dlan17 avatar ezequielgarcia avatar intelfx avatar mpe avatar neheb avatar stephenfin avatar threexc avatar tromey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

git-pw's Issues

HTTP 500 errors are not handled correctly

Hi,

I have an issue running git-pw against the recently upgraded patchwork for the DPDK project: http://dpdk.org/dev/patchwork/project/dpdk/

I installed and configured git-pw as follows:

pip install git-pw

git-pw --version
   git-pw, version 1.1.2

git config pw.server   http://dpdk.org/dev/patchwork/
git config pw.project  dpdk
git config pw.username johnmcnamara
git config pw.password password

Running commands such as git-pw patch list --state new work fine.

However I have issues applying a patch:

$ git-pw --debug patch apply 40648 
2018-06-06 19:35:01,556 - git_pw.patch - INFO - Applying patch: id=40648, series=None, deps=True, args=
2018-06-06 19:35:01,565 - git_pw.config - DEBUG - Retrieved 'server' setting from git-config
2018-06-06 19:35:01,565 - git_pw.config - DEBUG - Retrieved 'server' setting from cache
2018-06-06 19:35:01,566 - git_pw.api - DEBUG - GET http://dpdk.org/dev/patchwork/api/patches/40648/
2018-06-06 19:35:01,580 - git_pw.config - DEBUG - Retrieved 'username' setting from git-config
2018-06-06 19:35:01,587 - git_pw.config - DEBUG - Retrieved 'password' setting from git-config
2018-06-06 19:35:01,587 - git_pw.config - DEBUG - Retrieved 'username' setting from cache
2018-06-06 19:35:01,587 - git_pw.config - DEBUG - Retrieved 'password' setting from cache
2018-06-06 19:35:01,591 - requests.packages.urllib3.connectionpool - INFO - Starting new HTTP connection (1): proxy.ir.intel.com
2018-06-06 19:35:01,980 - requests.packages.urllib3.connectionpool - DEBUG - "GET http://dpdk.org/dev/patchwork/api/patches/40648/ HTTP/1.1" 200 None
2018-06-06 19:35:02,007 - git_pw.api - DEBUG - Got response
2018-06-06 19:35:02,011 - git_pw.api - DEBUG - GET http://dpdk.org/dev/patchwork/patch/40648/mbox/
2018-06-06 19:35:02,019 - git_pw.config - DEBUG - Retrieved 'username' setting from cache
2018-06-06 19:35:02,019 - git_pw.config - DEBUG - Retrieved 'password' setting from cache
2018-06-06 19:35:02,019 - git_pw.config - DEBUG - Retrieved 'username' setting from cache
2018-06-06 19:35:02,019 - git_pw.config - DEBUG - Retrieved 'password' setting from cache
2018-06-06 19:35:02,022 - requests.packages.urllib3.connectionpool - INFO - Starting new HTTP connection (1): proxy.ir.intel.com
2018-06-06 19:35:02,176 - requests.packages.urllib3.connectionpool - DEBUG - "GET http://dpdk.org/dev/patchwork/patch/40648/mbox/?series=%2A HTTP/1.1" 500 None
Traceback (most recent call last):
  File "/usr/bin/git-pw", line 11, in <module>
    sys.exit(cli())
  File "/usr/lib/python2.7/site-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python2.7/site-packages/click/core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python2.7/site-packages/click/core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python2.7/site-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python2.7/site-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/git_pw/patch.py", line 41, in apply_cmd
    mbox = api.download(patch['mbox'], {'series': series})
  File "/usr/lib/python2.7/site-packages/git_pw/api.py", line 141, in download
    rsp = get(url, params, stream=True)
  File "/usr/lib/python2.7/site-packages/git_pw/api.py", line 103, in get
    _handle_error('fetch', exc)
  File "/usr/lib/python2.7/site-packages/git_pw/api.py", line 81, in _handle_error
    LOG.error(exc.response.json())
  File "/usr/lib/python2.7/site-packages/requests/models.py", line 826, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/lib64/python2.7/json/__init__.py", line 339, in loads
    return _default_decoder.decode(s)
  File "/usr/lib64/python2.7/json/decoder.py", line 364, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib64/python2.7/json/decoder.py", line 382, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

Running http://dpdk.org/dev/patchwork/patch/40648/mbox/?series=%2A manually fails.
However, http://dpdk.org/dev/patchwork/patch/40648/mbox/?series= (without the encoded *) works.

The command also works if I modify git-pw to use '' instead of '*' for undefined series.

Is this a server config issue or a client issue?

John

Errors are not handled correctly

Using an invalid state causes an exception

$ git pw patch update 869747 --state=superceded
Traceback (most recent call last):
  File "/home/sfinucan/.local/bin/git-pw", line 11, in <module>
    sys.exit(cli())
  File "/home/sfinucan/.local/lib/python2.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/sfinucan/.local/lib/python2.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/sfinucan/.local/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/sfinucan/.local/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/sfinucan/.local/lib/python2.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/sfinucan/.local/lib/python2.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/sfinucan/.local/lib/python2.7/site-packages/git_pw/patch.py", line 164, in update_cmd
    patch = api.update('patches', patch_id, data)
  File "/home/sfinucan/.local/lib/python2.7/site-packages/git_pw/api.py", line 175, in update
    return put(url, data).json()
  File "/home/sfinucan/.local/lib/python2.7/site-packages/git_pw/api.py", line 100, in put
    LOG.error(exc.response.json()['detail'])
KeyError: 'detail'

`git pw patch list` doesn't show all the patches

Instance: patchwork.kernel.org
Project: platform-driver-x86

For example, patches with the status "Superseded" or "Not Applicable" simple skipped. pwclient shows them correctly.

git pw patch list --state superseded shows them as well, but I want to have everything which is not archived to be shown by default.

UnicodeEncodeError: 'ascii' codec can't encode characters in position 1005-1007: ordinal not in range(128)

While applying a series from patchwork, I ran into the following error:

Traceback (most recent call last):
  File "/usr/bin/git-pw", line 11, in <module>
    sys.exit(cli())
  File "/usr/lib/python2.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python2.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python2.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/git_pw/series.py", line 41, in apply_cmd
    p.communicate(mbox)
  File "/usr/lib64/python2.7/subprocess.py", line 465, in communicate
    self.stdin.write(input)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 1005-1007: ordinal not in range(128)

UpdateTestCase.test_update_with_invalid_state fails with 1.8.0 on python 3.8

[    5s] ________________ UpdateTestCase.test_update_with_invalid_state _________________
[    5s] 
[    5s] self = <tests.test_patch.UpdateTestCase testMethod=test_update_with_invalid_state>
[    5s] mock_states = <MagicMock name='_get_states' id='140036334190800'>
[    5s] mock_show = <MagicMock name='_show_patch' id='140036334163664'>
[    5s] mock_update = <MagicMock name='update' id='140036333614096'>
[    5s] 
[    5s]     def test_update_with_invalid_state(
[    5s]             self, mock_states, mock_show, mock_update):
[    5s]         """Validate behavior with invalid state."""
[    5s]     
[    5s]         mock_states.return_value = ['foo']
[    5s]     
[    5s]         runner = CLIRunner()
[    5s]         result = runner.invoke(patch.update_cmd, [
[    5s]             '123', '--state', 'bar'])
[    5s]     
[    5s]         assert result.exit_code == 2, result
[    5s] >       assert 'Invalid value for "--state"' in result.output, result
[    5s] E       AssertionError: <Result SystemExit(2,)>
[    5s] E       assert 'Invalid value for "--state"' in "Usage: update [OPTIONS] PATCH_IDS...\nTry 'update --help' for help.\n\nError: Invalid value for '--state': invalid choic...w, under-review, accepted, rejected, rfc, not-applicable, changes-requested, awaiting-upstream, superseded, deferred)\n"
[    5s] E        +  where "Usage: update [OPTIONS] PATCH_IDS...\nTry 'update --help' for help.\n\nError: Invalid value for '--state': invalid choic...w, under-review, accepted, rejected, rfc, not-applicable, changes-requested, awaiting-upstream, superseded, deferred)\n" = <Result SystemExit(2,)>.output
[    5s] 
[    5s] tests/test_patch.py:263: AssertionError

Complete build log

use git-pw to download patches, but sometimes can not download or can not fully download

1.I have configured my git-pw with
pw.server="xxx"
pw.token="xxx"
pw.project="xxx"

2.A series of 370 patches has been stored in my patchwork server, but when I use "git-pw series download series_id /home/patches/xx/",
I have found just 167 patches have been downloaded in the content of /home/patches/xx/xxx.patch

need some help to resolve this, thanks

Fix handling options on git pw series apply

git pw series apply -s <series ID> gives Error: Invalid value for "SERIES_ID": -s is not a valid integer.

git pw series apply <series ID> -s works as expected, fetching the series and applying the patches with the signoff by passing through the -s to git am.

This is probably some quirk of the command line parser.

git pw patch apply --help does not mention what ARGS mean

I tried:

bapiya. git pw patch apply --help
Usage: git-pw patch apply [OPTIONS] PATCH_ID [ARGS]...

  Apply patch.

  Apply a patch locally using the 'git-am' command.
[...]

Nothing says here what ARGS means. I thought maybe it would let me pass options to git am, but unfortunately it doesn't. (I'll file another bug for that.)

Configuration files

At present, configuration can be loaded from one of three places (in order of priority):

  1. Environment flags, e.g. PW_USERNAME
  2. Command-line options, e.g. --username
  3. The git-config cache, e.g. git config pw.username

There's no reason to break this. However, we should add a fourth mechanism: configuration files. This would allow us to distribute the configuration as part of source control. This configuration file could take the format of pwclientrc files. However, we may also wish to learn from some of the mistakes of that format.

If we do this, we may also wish to add an init sub-command, which would initialize the git-config cache with this data.

`patch list` is not so usable when tons of patches are available

Here is an issue with git pw patch list.
It can't show properly the limit of commits. --limit=0 does not affect anything (I'm expecting no limit, or server defined limit), --limit=1000 shows 1000 patches, however, I would rather need only few patches by given submitter (okay, this wouldn't work with API 1.0), or for given date (or period in time).
So, git pw patch list --date=today or alike is what being missed.

git pw uses pager differently from the rest of git

git help config explains git's approach to choosing the pager and pager options. However, git pw does not follow this same approach. I was hoping that git pw would do what the rest of git did; the difference is pronounced enough in my case that I wind up invoking git pw | cat quite a bit.

python integration not working

Hi,

I'm trying to run equivalent of following command:
$ git-pw patch list --limit 5

by using following Python code:

from git_pw import patch
print patch.list_cmd((u'under-review', u'new'),(),(), False, 5, None, '-date', None)

The parameters I'm passing to list_cmd should be OK. I've instrumented git_pw/patch.py to have them printed before running $ git-pw patch list --limit 5.

Unfortunately, my Python example doesn't work:

Traceback (most recent call last):
  File "./testcase.py", line 3, in <module>
    print patch.list_cmd((u'under-review', u'new'),(),(), False, 5, None, '-date', None)
  File "/usr/lib/python2.7/site-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
TypeError: main() takes at most 5 arguments (9 given)

It looks like the interface is broken, could you please fix it?

packaging for Gentoo Linux

hello, I'm trying to pack this great tool for Gentoo Linux, while face a build err.
It fail to find version info from PKG-INFO or METADATA (which both files not found)

>>> Source configured.
>>> Compiling source in /var/tmp/portage/dev-vcs/git-pw-2.0.0/work/git-pw-2.0.0 ...
 * python3_8: running distutils-r1_run_phase distutils-r1_python_compile
python3.8 setup.py build -j 30
/usr/lib/python3.8/site-packages/setuptools/dist.py:642: UserWarning: Usage of dash-separated 'description-file' will not be supported in future versions. Please use the underscore name 'description_file' instead
  warnings.warn(
ERROR:root:Error parsing
Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/pbr/core.py", line 96, in pbr
    attrs = util.cfg_to_args(path, dist.script_args)
  File "/usr/lib/python3.8/site-packages/pbr/util.py", line 271, in cfg_to_args
    pbr.hooks.setup_hook(config)
  File "/usr/lib/python3.8/site-packages/pbr/hooks/__init__.py", line 25, in setup_hook
    metadata_config.run()
  File "/usr/lib/python3.8/site-packages/pbr/hooks/base.py", line 27, in run
    self.hook()
  File "/usr/lib/python3.8/site-packages/pbr/hooks/metadata.py", line 25, in hook
    self.config['version'] = packaging.get_version(
  File "/usr/lib/python3.8/site-packages/pbr/packaging.py", line 874, in get_version
    raise Exception("Versioning for this project requires either an sdist"
Exception: Versioning for this project requires either an sdist tarball, or access to an upstream git repository. It's also possible that there is a mismatch between the package name in setup.cfg and the argument given to pbr.version.VersionInfo. Project name git-pw was given, but was not able to be found.
error in setup command: Error parsing /var/tmp/portage/dev-vcs/git-pw-2.0.0/work/git-pw-2.0.0/setup.cfg: Exception: Versioning for this project requires either an sdist tarball, or access to an upstream git repository. It's also possible that there is a mismatch between the package name in setup.cfg and the argument given to pbr.version.VersionInfo. Project name git-pw was given, but was not able to be found.
 * ERROR: dev-vcs/git-pw-2.0.0::local failed (compile phase):
 *   (no error message)

Unicode decode issues CSV output

As discussed at #46 (comment)

...I'm now seeing a Unicode issue in another case.

Here is a dump from the DPDK patchwork which works:

$ git-pw patch list "bulk" --column ID --column Submitter
+-------+------------------------------------------+
|    ID | Submitter                                |
|-------+------------------------------------------|
| 59113 | Morten Brรƒยธrup ([email protected]) |
+-------+------------------------------------------+

However, with the CSV output it throws an exception

$ git-pw patch list "bulk" --column ID --column Submitter -f csv
Traceback (most recent call last):
  File "/usr/bin/git-pw", line 10, in <module>
    sys.exit(cli())
  File "/usr/lib/python2.7/site-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python2.7/site-packages/click/core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python2.7/site-packages/click/core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python2.7/site-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python2.7/site-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/lib/python2.7/site-packages/git_pw/api.py", line 303, in new_func
    return ctx.invoke(f, *args, **kwargs)
  File "/usr/lib/python2.7/site-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/git_pw/patch.py", line 265, in list_cmd
    utils.echo_via_pager(output, headers, fmt=fmt)
  File "/usr/lib/python2.7/site-packages/git_pw/utils.py", line 155, in echo_via_pager
    _echo_via_pager('less', output)
  File "/usr/lib/python2.7/site-packages/git_pw/utils.py", line 113, in _echo_via_pager
    c.stdin.write(line.encode(encoding, 'replace'))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 0: ordinal not in range(128)
"ID","Submitter"
"59113","Morten Br

'git pw bundle apply' is broken

$ git pw bundle apply 9813
Traceback (most recent call last):
  File "/home/sfinucan/Development/patchwork/patchwork/.venv/bin/git-pw", line 10, in <module>
    sys.exit(cli())
  File "/home/sfinucan/Development/patchwork/patchwork/.venv/lib/python2.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/sfinucan/Development/patchwork/patchwork/.venv/lib/python2.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/sfinucan/Development/patchwork/patchwork/.venv/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/sfinucan/Development/patchwork/patchwork/.venv/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/sfinucan/Development/patchwork/patchwork/.venv/lib/python2.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/sfinucan/Development/patchwork/patchwork/.venv/lib/python2.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/sfinucan/Development/patchwork/git-pw/git_pw/bundle.py", line 52, in apply_cmd
    mbox = api.download(bundle['mbox']).text
AttributeError: 'str' object has no attribute 'text'

Not possible to download to stdout on Python 3

This seems to be because we're using requests Response.text, which returns a decoded string, rather than Response.content, which returns bytes.

$ git-pw patch download 1161653 -
Traceback (most recent call last):
  File "/home/sfinucan/.local/bin/git-pw", line 10, in <module>
    sys.exit(cli())
  File "/home/sfinucan/.local/lib/python3.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/sfinucan/.local/lib/python3.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/sfinucan/.local/lib/python3.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/sfinucan/.local/lib/python3.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/sfinucan/.local/lib/python3.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/sfinucan/.local/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/sfinucan/.local/lib/python3.7/site-packages/git_pw/patch.py", line 77, in download_cmd
    output.write(content)
TypeError: a bytes-like object is required, not 'str'

Version on pip is outdated, docs are confusing

There has apparently been a major rework of the interface here, which looks good overall. Unfortunately, the suggestion to use "pip install git-pw" is, at the moment, very bad advice:

  • You get the 0.2.0 version interface
  • The docs point you to the new interface

Very confusing. Suggest making a new release and uploading it to pip soon if you can; or at least taking the suggestion to use pip out of the README.

Patches are dumped to local directory

The git pw patch apply command and other commands that result in patches being downloaded will result in .patch files being dumped to the local working directory. This is mildly annoying as you need to clean these up after. We should instead dump to a temporary directory.

Meta data for mail replies in git pw series show

This sort of goes in line with issue #50, I would like a way to extract all participants the patchwork series has been sent to and dump it in git pw series show. Example for reply instructions from lore https://lore.kernel.org/bpf/[email protected]/#R which shows the full to/cc chain and in-reply-to ID. Ideally could be dumped in the series show. Given I can see stored 'Headers' in the patchwork UI, this info should be available, but not yet accessible via API / tooling afaik.

Add a Link to message-id in the commit message

The Linux kernel changelog format is evolving and requests to add:
Link://lore.kernel.org/lkml/$Message-ID
in order to help tracking the submitted/merged patches. This line must be the first one in tags list.

This can be deduced from the and options.

Would it be possible to have an option to add this tag (may be configurable to let other projects to specify their own format)?

'Message ID' field in git pw series show

The git pw patch show shows the Message ID field, which is great. When I do a git pw series show, I would love to have the Message ID field as well. In case of a series with a cover letter, that should point to the Message ID of the cover letter, and if the former is not present, then it should point to the first patch in the series. Seems even right now this cannot be scripted since I cannot do git pw patch show <cover-id> if I take the from git pw series show. It would be really useful to have so one can script automated replies.

Add support for applying dependent patches when applying a patch

The DPDK project has defined syntax for a "Depends-on" tag. A contributor can add this label to their patch or cover letter if it depends on another patch or series that has not yet been applied to the target branch.

The syntax for this tag and where it appears in a patch file is as follows:

... MIME headers and such go here ...

Some commit message

Signed-off-by: someone
---
Depends-on: patch-##### ("title of patch")
Depends-on: series-##### ("title of series")

... git diff summary goes here ...

---
... diff goes here ...

There can be multiple of these tags defined with differing values. An implementation is intended to collect them into a list. When applying a patch which has these tags, they should be applied in the order listed in the patch file. This process is not recursive, as in if the dependents of a patch have additional dependents, those are not applied.

The ask is for, when running git pw patch apply <id> or git pw series apply <id>, the command will scan for these dependent patches or series and apply them automatically as described above.

Would this functionality be useful to other projects, and appropriate to add to git-pw?

'git-pw patch list' returns an empty list

I cannot get this to work, surely missing something.

Values are also set in .git/config file. They are the same. I put the command line equivalent here for lisibility.

git-pw \
--debug \
--username <user> \
--password <pass> \
--server https://patchwork.ozlabs.org/api/1.1 \
--project https://patchwork.ozlabs.org/project/uboot/list/ patch list

This is the CLI output:

2020-04-10 06:36:30,693 - git_pw.config - DEBUG - Retrieved 'server' setting from cache
2020-04-10 06:36:30,693 - git_pw.config - DEBUG - Retrieved 'server' setting from cache
2020-04-10 06:36:30,694 - git_pw.patch - DEBUG - List patches: states=under-review,new, submitters=, delegates=, archived=False
2020-04-10 06:36:30,694 - git_pw.config - DEBUG - Retrieved 'server' setting from cache
2020-04-10 06:36:30,694 - git_pw.config - DEBUG - Retrieved 'server' setting from cache
2020-04-10 06:36:30,694 - git_pw.config - DEBUG - Retrieved 'project' setting from cache
2020-04-10 06:36:30,694 - git_pw.config - DEBUG - Retrieved 'project' setting from cache
2020-04-10 06:36:30,694 - git_pw.config - DEBUG - Retrieved 'project' setting from cache
2020-04-10 06:36:30,694 - git_pw.config - DEBUG - Retrieved 'project' setting from cache
2020-04-10 06:36:30,694 - git_pw.api - DEBUG - GET http://patchwork.ozlabs.org/api/1.1/patches/
2020-04-10 06:36:30,698 - git_pw.config - DEBUG - Retrieved 'username' setting from cache
2020-04-10 06:36:30,698 - git_pw.config - DEBUG - Retrieved 'password' setting from cache
2020-04-10 06:36:30,698 - git_pw.config - DEBUG - Retrieved 'username' setting from cache
2020-04-10 06:36:30,698 - git_pw.config - DEBUG - Retrieved 'password' setting from cache
2020-04-10 06:36:30,701 - urllib3.connectionpool - DEBUG - Starting new HTTP connection (1): patchwork.ozlabs.org:80
2020-04-10 06:36:31,384 - urllib3.connectionpool - DEBUG - http://patchwork.ozlabs.org:80 "GET /api/1.1/patches/?state=under-review
&state=new&archived=false&order=-date&project=http%3A%2F%2Fpatchwork.ozlabs.org%2Fproject%2Fuboot%2Flist%2F HTTP/1.1" 200 2
2020-04-10 06:36:31,385 - git_pw.api - DEBUG - Got response

Log inadvertently printed on Python 3

There's an info-level log emitted when downloading patches. This shouldn't be emitted when downloading to STDOUT (e.g. git pw patch download NNN -) and indeed this is the case on Python 2 but not Python 3.

'git-pw patch list --delegate foo' fails

Running the above command results in:

[dzickus@dzickus-laptop rhel7]$ git-pw --debug patch list --delegate foo
2018-03-13 11:01:46,012 - git_pw.patch - INFO - List patches:
states=under-review,new, submitters=, delegates=foo, archived=False
2018-03-13 11:01:46,022 - git_pw.config - DEBUG - Retrieved 'server' setting
from git-config
2018-03-13 11:01:46,022 - git_pw.config - DEBUG - Retrieved 'server' setting
from cache
Traceback (most recent call last):
  File "/home/dzickus/bin/git-pw", line 10, in <module>
    sys.exit(cli())
  File "/usr/lib/python2.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python2.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python2.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/dzickus/lib/python/git_pw/patch.py", line 216, in list_cmd
    users = api.index('users', {'q': delg})
  File "/home/dzickus/lib/python/git_pw/api.py", line 172, in index
    params.append(('project', _get_project()))
AttributeError: 'dict' object has no attribute 'append'

YAML output isn't useful

For example:

$ git-pw series show 17817 -fyaml
- property: ID
  value: 17817
- property: Date
  value: '2023-10-16T19:44:55'
- property: Name
  value: 'patchtest: add to oe-core'
- property: URL
  value: https://patchwork.yoctoproject.org/project/oe-core/list/?series=17817
- property: Submitter
  value: Trevor Gamblin ([email protected])
- property: Project
  value: OpenEmbedded Core Layer
- property: Version
  value: 1
- property: Received
  value: 4 of 4
- property: Complete
  value: true
- property: Cover
  value: '717  [0/4] patchtest: add to oe-core'
- property: Patches
  value: '32402 [1/4] patchtest/requirements.txt: update'
- property: ''
  value: '32405 [2/4] patchtest: add supporting modules'
- property: ''
  value: '32404 [3/4] patchtest: add scripts to oe-core'
- property: ''
  value: '32403 [4/4] patchtest: set default repo and testdir targets'

The patches are not expressed in yaml in a way that is actually parsable.

No man pages for PyPI packages

I installed git-pw using pip. I was hoping to read the manual using "git help pw", like I do for other git commands, but this did not work.

Issue with unquoted csv output format

Some output fields from git-pw contain commas which break the CSVoutput.

For example consider a query like this against the DPDK Patchwork:

$ git-pw patch list RFC --column ID --column Name --limit 4
+-------+-----------------------------------------------------------------+
|    ID | Name                                                            |
|-------+-----------------------------------------------------------------|
| 59107 | [RFC] kni: properly translate pa2va for cloned mbuf             |
| 59106 | [RFC,v3,4/4] app/testpmd: show the Rx/Tx burst mode description |
| 59105 | [RFC,v3,3/4] net/ice: support to get the Rx/Tx burst mode       |
| 59104 | [RFC,v3,2/4] net/i40e: support to get the Rx/Tx burst mode      |
+-------+-----------------------------------------------------------------+

If you then add the format csv option you get this:

$ git-pw patch list RFC --column ID --column Name --limit 4 -f csv
ID,Name
59107,[RFC] kni: properly translate pa2va for cloned mbuf
59106,[RFC,v3,4/4] app/testpmd: show the Rx/Tx burst mode description
59105,[RFC,v3,3/4] net/ice: support to get the Rx/Tx burst mode
59104,[RFC,v3,2/4] net/i40e: support to get the Rx/Tx burst mode

The commas in the Name fields means that there are too many CSV fields. I'd guess that they should be quoted:

$ git-pw patch list RFC --column ID --column Name --limit 4 -f csv
ID,Name
59107,"[RFC] kni: properly translate pa2va for cloned mbuf"
59106,"[RFC,v3,4/4] app/testpmd: show the Rx/Tx burst mode description"
59105,"[RFC,v3,3/4] net/ice: support to get the Rx/Tx burst mode"
59104,"[RFC,v3,2/4] net/i40e: support to get the Rx/Tx burst mode"

Version is 1.6.0 from the current HEAD:

$ git-pw --version
git-pw, version 1.6.0

README on github has broken URL

The last two hyperlinks in README.rst render incorrectly on github. The "Read The Docs" link is broken, and the "editable" link instead points to the readthedocs link.

image

git-pw can't find patch by author's name

I'm not sure if this is a git-pw bug or a patchwork bug or a bug in our installation. I filed it here since I observed it with git-pw, and because searching for the author's name in the patchwork web UI did find the patch.

If I ask for a patch by author, git-pw does not find it. However, if I use the email address, the patch is found -- and it shows the author's name.

I have an example here, but since it is a real user I didn't feel comfortable posting their name and email address. I could obfuscate it if that would be useful in any way.

`git pw patch update` is too slow

Rather the point to confirm than the bug.

Instance: patchwork.ozlabs.org
Amount of patches: 15

% time git pw patch update --state superseded --archived yes $(seq 993588 993602)
...
real    0m44.679s
user    0m0.701s
sys     0m0.223s

Instance: patchwork.kernel.org
Amount of patches: 13

% time tsocks pwclient update -a yes -s Superseded 9244263 9244267 9244279 9244281 9244285 9244293 9244303 9244309 9244311 9244319 9244321 9244327 9244335

real    0m12.203s
user    0m0.097s
sys     0m0.024s

'git pw patch apply' failure output is malformatted on Python 3

For example:

$ git pw patch apply 1143785
b'Applying: filters: re-add the possibility of filtering undelegated patches\nUsing index info to reconstruct a base tree...\nM\tpatchwork/filters.py\nM\tpatchwork/templates/patchwork/partials/filters.html\nFalling back to patching base and 3-way merge...\nAuto-merging patchwork/filters.py\nCONFLICT (content): Merge conflict in patchwork/filters.py\nRecorded preimage for \'patchwork/filters.py\'\nerror: Failed to merge in the changes.\nhint: Use \'git am --show-current-patch\' to see the failed patch\nPatch failed at 0001 filters: re-add the possibility of filtering undelegated patches\nWhen you have resolved this problem, run "git am --continue".\nIf you prefer to skip this patch, run "git am --skip" instead.\nTo restore the original branch and stop patching, run "git am --abort".\n'

I assume we're not decoding something.

The '--state' option doesn't seem to do anything

Passing the --state option to git-pw patch list doesn't appear to do anything.

$ git-pw --debug patch list --state new                                                                                                                                                                            
2017-08-28 14:09:04,237 - git_pw.patch - INFO - List patches: states=new, submitters=, delegates=, archived=False                                                                                                  
2017-08-28 14:09:04,240 - git_pw.config - DEBUG - Retrieved 'project' setting from git-config            
2017-08-28 14:09:04,243 - git_pw.config - DEBUG - Retrieved 'server' setting from git-config             
2017-08-28 14:09:04,243 - git_pw.config - DEBUG - Retrieved 'server' setting from cache                  
2017-08-28 14:09:04,243 - git_pw.api - DEBUG - GET https://patchwork.ozlabs.org/api/patches/             
2017-08-28 14:09:04,246 - git_pw.config - DEBUG - Retrieved 'token' setting from git-config              
2017-08-28 14:09:04,246 - git_pw.config - DEBUG - Retrieved 'token' setting from cache                   
2017-08-28 14:09:04,248 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): patchwork.ozlabs.org                                                                                                 
2017-08-28 14:09:05,704 - urllib3.connectionpool - DEBUG - https://patchwork.ozlabs.org:443 "GET /api/patches/?project=patchwork&archived=1&order=-date HTTP/1.1" 200 None                                         
2017-08-28 14:09:06,026 - git_pw.api - DEBUG - Got response

(note the second URL - there's no state field there).

Filtering by state

We have a --state argument for git pw patch list, but it doesn't seem to be doing anything.

State should be case sensitive and follow the exact spelling

When run git pw patch update --state <STATE> I have to provide an exact spelling of the <STATE> in question. However, when I got information about current state (either via git pw path list or looking at the result page from git pw patch update --state <STATE>) I see it spelled wrong.

First attempt:

% git pw patch update 993589 --state superseeded # **UPDATE** typo is here!

{u'state': [u'Invalid state superseeded. Expected one of: New, Under Review, Accepted, Rejected, RFC, Not Applicable, Changes Requested, Awaiting Upstream, Superseded, Deferred, Needs Review / ACK.']}

Second attempt:

% git pw patch update 993589 --state Superseded
| State      | superseded                                                              |

P.S. Under Review is spelled as under-review inside the tool which is wrong. pwclient doesn't have such issue.

Allow pw.token to be stored outside config file

I would like to be able to configure pw.token to name a file or program producing a token. That way, if while debugging I send someone output of "git config -l", then I won't expose my token.

For example, if git-pw could obtain the token using a credential helper http://www.kernel.org/pub/software/scm/git/docs/gitcredentials.html then that would be perfect for me. (As a bonus, that would allow other people to store the token in their platform's standard keychain.)

"Download only" mode?

My usecase is to download a patch series from a patchwork instance. git-pw requires authentication even when I don't want to manipualte the state patches.

Is there any interest in a "download only" mode which skips authentication?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.