]> git.ipfire.org Git - thirdparty/patchwork.git/log
thirdparty/patchwork.git
7 years agodocs: Update copyright and remove dead code
Stephen Finucane [Thu, 17 May 2018 09:34:04 +0000 (10:34 +0100)] 
docs: Update copyright and remove dead code

We're firmly in 2018 now and we're also using sphinx_rtd_theme 0.3.0.
This means we can bump the copyright and remove what is now dead code.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Acked-by: Daniel Axtens <dja@axtens.net>
7 years agodocs: Update release, contributing guides
Stephen Finucane [Wed, 16 May 2018 13:29:34 +0000 (14:29 +0100)] 
docs: Update release, contributing guides

Document the requirement to send an email to the list upon a release and
to always send patches via email.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Acked-by: Daniel Axtens <dja@axtens.net>
7 years agodocs: Resolve typos in release notes
Stephen Finucane [Thu, 17 May 2018 09:38:26 +0000 (10:38 +0100)] 
docs: Resolve typos in release notes

Signed-off-by: Stephen Finucane <stephen@that.guru>
7 years agoREST: Disable control for filtering patches by series in web view
Daniel Axtens [Fri, 11 May 2018 17:00:44 +0000 (03:00 +1000)] 
REST: Disable control for filtering patches by series in web view

As with the events view, creating and rendering the control for
filtering patches by series creates a massive slowdown. It's a little
sad not to be able to do this in the web UI as filtering patches
by series does make sense, but hopefully people figure out you can
still do it, just not from the web view.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: Stephen Finucane <stephen@that.guru>
7 years agodocs: Add 'local' argument to 'contents'
Stephen Finucane [Wed, 9 May 2018 17:02:00 +0000 (18:02 +0100)] 
docs: Add 'local' argument to 'contents'

This means the page title won't be included in the table of contents,
which makes sense. I'm not really sure why this isn't the default, to be
honest.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Signed-off-by: Daniel Axtens <dja@axtens.net>
7 years agodocs: Add additional information about API versions
Stephen Finucane [Wed, 9 May 2018 17:01:59 +0000 (18:01 +0100)] 
docs: Add additional information about API versions

As we're soon going to be supporting a v1.1 API, we should document what
versions are available and whether they're supported still (hint: we
support both v1.0 and v1.1 at present).

Signed-off-by: Stephen Finucane <stephen@that.guru>
Signed-off-by: Daniel Axtens <dja@axtens.net>
7 years agoRevert "api: Only provide JSON version of events list"
Stephen Finucane [Thu, 10 May 2018 14:45:06 +0000 (15:45 +0100)] 
Revert "api: Only provide JSON version of events list"

This reverts commit 90d9ee14e73e8ec9248e89c788d64867c4a4bb74.

The root cause of this performance issue was not the use of the
JSONRenderer but rather the population of filter forms. The latter is
now disabled, meaning we can start using the original renderer.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Cc: Daniel Axtens <dja@axtens.net>
Acked-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: Daniel Axtens <dja@axtens.net>
7 years agoREST: Resolve performance issues with '/events' web view
Stephen Finucane [Thu, 10 May 2018 14:45:05 +0000 (15:45 +0100)] 
REST: Resolve performance issues with '/events' web view

The dropdown select-based filters in the web view of the REST API have
stung us a few times. In this case, populating these filters for the
'/events' endpoint results in a huge query that hammers the database and
results in seriously laggy responses.

The root cause of this performance issues was erroneously identified as
an issue with the JSON renderer so that particular patch can now be
reverted. This will be done separately.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Cc: Daniel Axtens <dja@axtens.net>
Tested-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: Daniel Axtens <dja@axtens.net>
7 years agoREST: Use DRF-specific filterset
Stephen Finucane [Wed, 11 Apr 2018 16:13:38 +0000 (17:13 +0100)] 
REST: Use DRF-specific filterset

This variant of 'FilterSet' will convert a 'django.forms.ValidationError',
which wouldn't be handled by DRF, to a
'rest_framework.exceptions.ValidationError', which would be.

Signed-off-by: Stephen Finucane <stephen@that.guru>
[dja: commit message]
Signed-off-by: Daniel Axtens <dja@axtens.net>
7 years agoREST: Use ModelMultipleChoiceField for other fields
Stephen Finucane [Wed, 11 Apr 2018 16:13:37 +0000 (17:13 +0100)] 
REST: Use ModelMultipleChoiceField for other fields

There's benefit to being able to do stuff like select multiple patches.
Let's do that.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Signed-off-by: Daniel Axtens <dja@axtens.net>
7 years agoREST: Rename Filter -> FilterSet
Stephen Finucane [Wed, 11 Apr 2018 16:13:36 +0000 (17:13 +0100)] 
REST: Rename Filter -> FilterSet

FilterSets are to Forms as Filters are to Fields: the former is
made up of the latter. We have a FilterSet for each resource that we
wish to support filtering on (i.e. all of them).

Rename our "Filters" to the more appropriate FilterSets.
The old name was confusing and will conflict with some forthcoming changes.

Signed-off-by: Stephen Finucane <stephen@that.guru>
[dja: commit message]
Signed-off-by: Daniel Axtens <dja@axtens.net>
7 years agoREST: Remove ProjectFilterMixin
Stephen Finucane [Wed, 11 Apr 2018 16:13:35 +0000 (17:13 +0100)] 
REST: Remove ProjectFilterMixin

Whatever benefits this was giving us in the past are no more and it
simply confuses matters now.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: Daniel Axtens <dja@axtens.net>
7 years agoREST: Base filters on Django's ModelMultipleChoiceField
Stephen Finucane [Wed, 11 Apr 2018 16:13:34 +0000 (17:13 +0100)] 
REST: Base filters on Django's ModelMultipleChoiceField

Introduce a modified version of Django's ModelMultipleChoiceField
that allows us to query on multiple fields.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: #156
[dja: commit message, expand docs]
Signed-off-by: Daniel Axtens <dja@axtens.net>
7 years agoREST: Simplify ModelMultiChoiceField
Stephen Finucane [Wed, 11 Apr 2018 16:13:33 +0000 (17:13 +0100)] 
REST: Simplify ModelMultiChoiceField

We're actually going to remove this shortly but the new technique works
for both the current approach and the approach we adopt in future patches.

Signed-off-by: Stephen Finucane <stephen@that.guru>
[dja: commit message, drop dead code]
Signed-off-by: Daniel Axtens <dja@axtens.net>
7 years agoREST: Use UserFilter for patch delegates
Stephen Finucane [Wed, 11 Apr 2018 16:13:32 +0000 (17:13 +0100)] 
REST: Use UserFilter for patch delegates

Signed-off-by: Stephen Finucane <stephen@that.guru>
Signed-off-by: Daniel Axtens <dja@axtens.net>
7 years agodocs: Bump API version in docs to 1.1
Stephen Finucane [Tue, 8 May 2018 08:18:22 +0000 (09:18 +0100)] 
docs: Bump API version in docs to 1.1

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: 81e6f8e4 ("docs: Prepare for 2.1.0-rc1")
Cc: Daniel Axtens <dja@axtens.net>
Signed-off-by: Daniel Axtens <dja@axtens.net>
7 years agoskip original Content-Transfer-Encoding for mbox
Yuri Volchkov [Mon, 7 May 2018 15:57:55 +0000 (01:57 +1000)] 
skip original Content-Transfer-Encoding for mbox

In the commit 01b9cbb9 all original mail headers are copied into the
resulted mbox file. This means that some headers are going to be
present twice in the generated mbox. That is fine unless the original
email arrived in base64 encoding.

Apparently git relies on the latest Content-Transfer-Encoding key. And
since downloaded patch's actual encoding is '7bit', git fails to apply
it with the message 'Patch is empty'.

Since patchwork adds a proper 'Content-Transfer-Encoding' anyways,
let's skip this field while copying headers from the original mail

Signed-off-by: Yuri Volchkov <yuri.volchkov@gmail.com>
Acked-by: Veronika Kabatova <vkabatov@redhat.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
7 years agoPatchwork v2.1.0-rc1 v2.1.0-rc1
Daniel Axtens [Thu, 5 Apr 2018 16:31:16 +0000 (02:31 +1000)] 
Patchwork v2.1.0-rc1

Signed-off-by: Daniel Axtens <dja@axtens.net>
7 years agodocs: Prepare for 2.1.0-rc1
Daniel Axtens [Thu, 5 Apr 2018 16:26:53 +0000 (02:26 +1000)] 
docs: Prepare for 2.1.0-rc1

Patchwork v2.1.0 will be Eolienne.

Move the "unreleased" notes to eolienne. We'll add a new 'unreleased'
right after tagging the final 2.1.0

Signed-off-by: Daniel Axtens <dja@axtens.net>
7 years agoExplicitly distinguish between comments on patch and cover
Veronika Kabatova [Thu, 3 May 2018 10:55:16 +0000 (12:55 +0200)] 
Explicitly distinguish between comments on patch and cover

reverse() gets confused when the same view name and kwargs are passed to
it, ignoring what endpoint the request originated from. Fix this by
using different view names for cover letter and patch comments views.

Reported-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: Veronika Kabatova <vkabatov@redhat.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
7 years agoparsemail: Clarify exit codes
Daniel Axtens [Mon, 30 Apr 2018 15:44:59 +0000 (01:44 +1000)] 
parsemail: Clarify exit codes

jk reports that the patchwork error codes are really unhelpful for
correct integration with an MDA. In particular they make sorting out
failures into a separate queue very difficult. Make this better and
clearer: only return 1 on a genuinely unexpected case that requires
adminstrator intervention.

Update the comment for parse_mail regarding return values and exceptions
to line up with how the function actually works and how we use the
results.

Update the tests. None of the existing tests should exit 1; they're
all 'expected' failures: unknown project etc. Also we removed the
exit(0) from the success path, so stop expecting that exception to
be raised.

Add a test for duplicates. That should also succeed without raising
an exception: dups are part of life.

Update parsearchive to deal with the fact that we can no longer
differentiate duplicates.

Reported-by: Jeremy Kerr <jk@ozlabs.org>
Fixes: #171
Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Stephen Finucane <stephen@that.guru>
7 years agodocker-compose: Re-add 'PGPASSWORD' to correct section
Stephen Finucane [Wed, 2 May 2018 15:06:25 +0000 (16:06 +0100)] 
docker-compose: Re-add 'PGPASSWORD' to correct section

This was moved in commit '1590c21d' but should not have been. Restore it
to its rightful place.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: 1590c21d ("docker-compose: Remove 'links' section")
Tested-by: Daniel Axtens <dja@axtens.net>
7 years agoREST: Show 'comments' in '/patches', '/comments'
Stephen Finucane [Fri, 27 Apr 2018 15:33:21 +0000 (16:33 +0100)] 
REST: Show 'comments' in '/patches', '/comments'

This link is only shown for individual resources at the moment. Modify
this behavior.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Acked-by: Veronika Kabatova <vkabatov@redhat.com>
7 years agoREST: Add comments to patch and cover endpoints
Veronika Kabatova [Wed, 25 Apr 2018 17:33:27 +0000 (19:33 +0200)] 
REST: Add comments to patch and cover endpoints

Signed-off-by: Veronika Kabatova <vkabatov@redhat.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
7 years agoUpdate Docker IP to whitelist for django-debug-toolbar
Stephen Finucane [Thu, 26 Apr 2018 23:19:32 +0000 (00:19 +0100)] 
Update Docker IP to whitelist for django-debug-toolbar

This has changed with the recent move to the 3.0 syntax.

Signed-off-by: Stephen Finucane <stephen@that.guru>
7 years agodocker: Add 'depends_on'
Stephen Finucane [Thu, 26 Apr 2018 13:47:40 +0000 (14:47 +0100)] 
docker: Add 'depends_on'

We need this for the PostgreSQL variant too.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: 1590c21d ("docker-compose: Remove 'links' section")
7 years agodocker: Add 'depends_on'
Stephen Finucane [Thu, 26 Apr 2018 12:45:50 +0000 (13:45 +0100)] 
docker: Add 'depends_on'

This is required now that we're no longer using links. Without it,
'docker-compose up' works but 'docker-compose run web' does not.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: 1590c21d ("docker-compose: Remove 'links' section")
7 years agodocker: Bump to bionic
Stephen Finucane [Tue, 17 Apr 2018 10:17:55 +0000 (11:17 +0100)] 
docker: Bump to bionic

As noted in commit 94dd1d411, we can and should start using Bionic once
it's out. This is now the case.

Signed-off-by: Stephen Finucane <stephen@that.guru>
7 years agodocker-compose: Remove 'links' section
Stephen Finucane [Tue, 17 Apr 2018 09:32:13 +0000 (10:32 +0100)] 
docker-compose: Remove 'links' section

This is no longer needed as the service name is also the host names in
v2 syntax [1].

[1] https://docs.docker.com/compose/networking/

Signed-off-by: Stephen Finucane <stephen@that.guru>
7 years agodocker-compose: Switch to 3.0 syntax
Stephen Finucane [Tue, 17 Apr 2018 08:58:00 +0000 (09:58 +0100)] 
docker-compose: Switch to 3.0 syntax

Ubuntu 18.04 (Bionic Beaver) providers 'docker-compose' 1.17.1 [1] at
release which supports the 3.0 syntax [2]. Using this allows some users
(me) to resolve a long standing issue caused by a UID that's not 1000.

[1] https://packages.ubuntu.com/bionic/docker-compose
[2] https://docs.docker.com/compose/compose-file/

Signed-off-by: Stephen Finucane <stephen@that.guru>
7 years agodocker: Remove bash aliases
Stephen Finucane [Tue, 17 Apr 2018 09:20:28 +0000 (10:20 +0100)] 
docker: Remove bash aliases

These seem to be a hangover from the Vagrant days. I don't personally
use them anymore and I'm not sure anyone else does. I think they can go.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Cc: Daniel Axtens <dja@axtens.net>
7 years agotests: Remove Selenium tests
Stephen Finucane [Tue, 17 Apr 2018 08:50:44 +0000 (09:50 +0100)] 
tests: Remove Selenium tests

These were added quite some time ago in order to allow some level of UI
testing. However, I've personally never used them, they're not used by
the CI, and no one has shown any desire in extending them in their time
here. It is time to bid these tests adieu.

Removing these allows us to remove a whole load of wiring that existed
just to enable these. Some of this, like the '--quick-tox' option for
the Dockerfile, is retained so we don't need to use different commands
for various versions of Patchwork, but the majority is just stripped
out.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Cc: Daniel Axtens <dja@axtens.net>
7 years agodocker: Replace tabs with spaces
Stephen Finucane [Tue, 17 Apr 2018 08:45:02 +0000 (09:45 +0100)] 
docker: Replace tabs with spaces

Maintain your chill, people.

Signed-off-by: Stephen Finucane <stephen@that.guru>
7 years agoUpdate django-debug-toolbar from 1.8 to 1.9.1
pyup-bot [Wed, 25 Apr 2018 21:39:42 +0000 (22:39 +0100)] 
Update django-debug-toolbar from 1.8 to 1.9.1

7 years agoUpdate sqlparse from 0.2.3 to 0.2.4
pyup-bot [Wed, 27 Sep 2017 07:55:45 +0000 (08:55 +0100)] 
Update sqlparse from 0.2.3 to 0.2.4

7 years agoUpdate sphinx_rtd_theme from 0.2.4 to 0.3.0
pyup-bot [Fri, 6 Apr 2018 15:25:09 +0000 (16:25 +0100)] 
Update sphinx_rtd_theme from 0.2.4 to 0.3.0

7 years agoResolve pep8 issues
Stephen Finucane [Wed, 25 Apr 2018 20:48:29 +0000 (21:48 +0100)] 
Resolve pep8 issues

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: 26f22a87 ("models: Add a backreference for a user's bundles")
7 years agomodels: Add a backreference for a user's bundles
Stephen Finucane [Thu, 12 Apr 2018 12:01:31 +0000 (13:01 +0100)] 
models: Add a backreference for a user's bundles

This is more intuitive.

Signed-off-by: Stephen Finucane <stephen@that.guru>
7 years agodocs: Add release note for changes to 'headers' field
Stephen Finucane [Wed, 25 Apr 2018 20:17:53 +0000 (21:17 +0100)] 
docs: Add release note for changes to 'headers' field

Signed-off-by: Stephen Finucane <stephen@that.guru>
7 years agoapi: Show all headers with the same key
Veronika Kabatova [Fri, 6 Apr 2018 11:24:49 +0000 (13:24 +0200)] 
api: Show all headers with the same key

While the code on our side returns all (key, value) pairs for email
headers, Django's REST framework probably uses dictionaries behind the
scenes. This means that having multiple headers with same key (eg
'Received', which is totally valid and common situation), only one of
these headers is visible in the REST API.

Let's hack around this by returning a list of values in case the key is
present multiple times.

Signed-off-by: Veronika Kabatova <vkabatov@redhat.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
7 years agodocs: Random fixes
Stephen Finucane [Sun, 15 Apr 2018 22:18:08 +0000 (23:18 +0100)] 
docs: Random fixes

Remove an unnecessary 'toctree' from the index page and fix some
definition lists.

Signed-off-by: Stephen Finucane <stephen@that.guru>
7 years agotests: Replace incorrect tests
Stephen Finucane [Tue, 17 Apr 2018 08:37:44 +0000 (09:37 +0100)] 
tests: Replace incorrect tests

In commit 683792d1, the 'test_api.py' was split into multiple
'api/test_xyz.py' files. As part of this change, the tests for cover
letter were mistakenly included in place of tests for checks. Correct
this oversight.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reported-by: Veronika Kabatova <vkabatov@redhat.com>
Acked-by: Veronika Kabatova <vkabatov@redhat.com>
Fixes: 683792d1 ("tests: Split 'test_rest_api'")
7 years agogitignore: Ignore '.venv'
Stephen Finucane [Wed, 11 Apr 2018 16:36:19 +0000 (17:36 +0100)] 
gitignore: Ignore '.venv'

I use this to validate stuff quite frequently. Ignore it so it's not
polluting my git-status.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Signed-off-by: Daniel Axtens <dja@axtens.net>
7 years agotox: Add 'docs' to default environments
Stephen Finucane [Wed, 11 Apr 2018 16:36:18 +0000 (17:36 +0100)] 
tox: Add 'docs' to default environments

I'd simply run 'tox' (via docker) to validate some previous patches.
Sadly that didn't catch a release note issue. Make sure this doesn't
happen again by always running 'docs'.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Signed-off-by: Daniel Axtens <dja@axtens.net>
7 years agodocs: Fix a release note issue
Stephen Finucane [Wed, 11 Apr 2018 16:36:17 +0000 (17:36 +0100)] 
docs: Fix a release note issue

You can't have a space before the closing double backticks of a literal
block. This was generating the following (unhelpful) error message:

  patchwork/docs/releases/unreleased.rst:82:Inline literal start-string
  without end-string.

reno should have better error messages but that's a problem for another
day.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Signed-off-by: Daniel Axtens <dja@axtens.net>
7 years agodocs: Read version from 'patchwork.VERSION'
Stephen Finucane [Wed, 11 Apr 2018 16:36:16 +0000 (17:36 +0100)] 
docs: Read version from 'patchwork.VERSION'

Because this isn't an installable package we need to do some path
hackery. Not the end of the world though.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Signed-off-by: Daniel Axtens <dja@axtens.net>
7 years agoFix stuff around mbox header changes
Veronika Kabatova [Tue, 10 Apr 2018 14:30:44 +0000 (16:30 +0200)] 
Fix stuff around mbox header changes

Bundle tests got broken after the subject in mbox was changed from the
parsed version to the original one because the tests checked for the
presence of patch's name in the response. Fixing this turned out to be
a bit tricky since the tests check the mbox attachment and HTML
responses separately, so we need a string that would be present in both
(the intuitive idea of checking X-Patchwork-Id won't work well).

Add the patch's name to the content of the test patch so we can continue
testing things the same way, checking for the presence of patch's name.

Also add a releasenote notifying about the inclusion of the original
headers.

Reverts: b2a25342 ("Use parsed subject for mboxes")
Fixes: 01b9cbb9 ("Include all email headers in mboxes")
Signed-off-by: Veronika Kabatova <vkabatov@redhat.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
7 years agogitignore: Ignore sql files
Stephen Finucane [Mon, 9 Apr 2018 21:04:36 +0000 (22:04 +0100)] 
gitignore: Ignore sql files

These are useful as backups.

Signed-off-by: Stephen Finucane <stephen@that.guru>
7 years agodocs: Add note on restoring the docker database
Stephen Finucane [Mon, 9 Apr 2018 14:59:36 +0000 (15:59 +0100)] 
docs: Add note on restoring the docker database

If you back something up, you'd probably want to restore it soon enough
too.

Signed-off-by: Stephen Finucane <stephen@that.guru>
7 years agotrivial: Remove additional Django < 1.8 code
Stephen Finucane [Sat, 7 Apr 2018 16:57:33 +0000 (17:57 +0100)] 
trivial: Remove additional Django < 1.8 code

Yet more stuff that was missed in the previous changes.

Signed-off-by: Stephen Finucane <stephen@that.guru>
7 years agoREST: Order 'filters' code
Stephen Finucane [Sun, 25 Mar 2018 18:28:23 +0000 (19:28 +0100)] 
REST: Order 'filters' code

Group custom filters and fields together followed by the actual filter
sets. This makes the file a little easier to comprehend.

Signed-off-by: Stephen Finucane <stephen@that.guru>
7 years agodocs: Add note on backing up the docker database
Stephen Finucane [Sun, 25 Mar 2018 18:28:22 +0000 (19:28 +0100)] 
docs: Add note on backing up the docker database

I'm sick of waiting for 'parsearchive' to finish.

Signed-off-by: Stephen Finucane <stephen@that.guru>
7 years agodocs: Add information on REST API versioning
Stephen Finucane [Sun, 25 Mar 2018 18:28:21 +0000 (19:28 +0100)] 
docs: Add information on REST API versioning

This isn't too prescriptive, given that so far we've only dealt with
adding new fields. However, it should serve as a guide to alert devs
that this stuff exists and should be a concern.

Signed-off-by: Stephen Finucane <stephen@that.guru>
7 years agoREST: Use versioning for modified responses
Stephen Finucane [Sun, 25 Mar 2018 18:28:20 +0000 (19:28 +0100)] 
REST: Use versioning for modified responses

This ensures clients are getting a consistent response if they request
the old version of the API. We do this by way of extensions to the
'HyperlinkedModelSerializer' class rather than duplicating the
serializers as it results in far less duplication. This approach won't
work for a MAJOR version bump but, all going well, it will be a while
before we have to deal with one of these.

The only two fields added since API 1.0 was released, 'cover.mbox' and
'project.subject_match', are handled accordingly.

Signed-off-by: Stephen Finucane <stephen@that.guru>
7 years agotests: Split 'test_rest_api'
Stephen Finucane [Sun, 25 Mar 2018 18:28:19 +0000 (19:28 +0100)] 
tests: Split 'test_rest_api'

Lay the tests out per the main code.

Signed-off-by: Stephen Finucane <stephen@that.guru>
7 years agoUse parsed subject for mboxes
Stephen Finucane [Sat, 7 Apr 2018 16:41:07 +0000 (17:41 +0100)] 
Use parsed subject for mboxes

With a recent change, we started using the original subject header
instead of the one we had already cleaned up at the parsing stage.
Revert this aspect of that change.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: 01b9cbb9 ("Include all email headers in mboxes")
7 years agoInclude all email headers in mboxes
Veronika Kabatova [Thu, 5 Apr 2018 15:51:58 +0000 (17:51 +0200)] 
Include all email headers in mboxes

Solves issue #165 (Exported mboxes should include In-Reply-To,
References, etc headers). Instead of including only a few chosen ones,
all received headers are added to mboxes.

Signed-off-by: Veronika Kabatova <vkabatov@redhat.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
7 years agoFix incorrect autodelegation documentation
Veronika Kabatova [Tue, 3 Apr 2018 16:18:36 +0000 (18:18 +0200)] 
Fix incorrect autodelegation documentation

The docs suggested to account for git prefixes (a/, b/) using eg.
?/patchwork/views/*. My rules didn't work so I tried bare path
(patchwork/views/*) instead. Looking at the code, the prefix really is
striped away (filename = '/'.join(filename.split('/')[1:])). Fix the
documentation to reflect on what is really happening.

Signed-off-by: Veronika Kabatova <vkabatov@redhat.com>
[dja: see 7bb0ebd78ff7 ("parser: Add patch_get_filenames()")]
Signed-off-by: Daniel Axtens <dja@axtens.net>
7 years agodocker: set timezone to Australia/Canberra
Daniel Axtens [Tue, 20 Mar 2018 22:34:15 +0000 (09:34 +1100)] 
docker: set timezone to Australia/Canberra

The tzinfo package isn't installed in docker, which makes the
default timezone UTC. This is unfortunate: the Django TZ in
settings/base.py is Australia/Canberra, and having a non-UTC
TZ is good for exposing faulty assumptions about what is and
isn't UTC.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Stephen Finucane <stephen@that.guru>
7 years agodocs: Update reference to kernel documentation
Ali Alnubani [Sat, 31 Mar 2018 13:56:00 +0000 (16:56 +0300)] 
docs: Update reference to kernel documentation

The referenced url was moved to Documentation/process.

Signed-off-by: Ali Alnubani <alialnu@mellanox.com>
Signed-off-by: Daniel Axtens <dja@axtens.net>
7 years agodocs: Fix package name
Ali Alnubani [Sat, 31 Mar 2018 13:55:59 +0000 (16:55 +0300)] 
docs: Fix package name

Fixed a typo that instructed to install tox instead
of reno.

Signed-off-by: Ali Alnubani <alialnu@mellanox.com>
Signed-off-by: Daniel Axtens <dja@axtens.net>
7 years agoapi: Only provide JSON version of events list
Daniel Axtens [Mon, 12 Mar 2018 12:08:54 +0000 (23:08 +1100)] 
api: Only provide JSON version of events list

Something is very, very slow in the d-r-f browsable API events renderer.

In my MySQL test (~33k patches), the CPU time to render the events list
is ~11s, and the time taken by SQL queries is only ~3s. If the JSON
renderer is used, that drops to 0.2s for the entire page (because less
CPU is used, and - for some as yet unknown reason - a *very* expensive
db query is dropped.)

In my PostgreSQL test (~100k patches), the results are even more stark:
30s of CPU time and 0.2s of DB time goes to 0.25s for the entire page.

Something is seriously, seriously wrong with whatever d-r-f is doing.
So, simply render the event list as unlinked JSON for now.

There are a few followups we should do, but this is an important start -
no-one should be able to DoS a patchwork server by just enumerating the
events!

In particular, we should find out:
 - why postgres and mysql behaviour is so different.
 - what on earth d-r-f is doing that makes rendering the pretty-printed
   version so incredibly slow.

Signed-off-by: Daniel Axtens <dja@axtens.net>
7 years agoapi: EventList: change select_related() to prefetch_related()
Daniel Axtens [Mon, 12 Mar 2018 11:07:15 +0000 (22:07 +1100)] 
api: EventList: change select_related() to prefetch_related()

select_related() creates a single giant query that JOINs the required
tables together in the DB. prefetch_related() does a similar thing,
but at the Django layer - for all referenced models, it makes a
separate query to the DB to fetch them.

This massively, massively simplifies the job the DB has to do:
instead of creating a massive, sparse results table with many
columns, we do 1 query for the events, and then query for only
patches/cover letters/series/projects etc referenced in those 30
events.

Tested with cURL + JSON renderer + Postgres w/ ~100k patches,
request time went from 1.5s to 0.25s, a 6x speedup.

Tested with cURL + JSON renderer + MySQL w/ ~33k patches,
request time went from ~2.2s to ~0.20s, an ~11x speedup.

Signed-off-by: Daniel Axtens <dja@axtens.net>
7 years agomigrations: Add missing migration
Stephen Finucane [Sun, 25 Mar 2018 16:14:53 +0000 (17:14 +0100)] 
migrations: Add missing migration

Add a migration that was missed in an earlier change.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: 0f25d8a15 ("Add validation for regular expressions")
7 years agoFix slow Patch counting query
Daniel Axtens [Thu, 8 Mar 2018 01:28:22 +0000 (12:28 +1100)] 
Fix slow Patch counting query

Stephen Rothwell noticed (way back in September - sorry Stephen!) that
the following query is really slow on OzLabs:

SELECT COUNT(*) AS "__count" FROM "patchwork_patch"
    INNER JOIN "patchwork_submission" ON
        ("patchwork_patch"."submission_ptr_id" = "patchwork_submission"."id")
    WHERE ("patchwork_submission"."project_id" = 14 AND
           "patchwork_patch"."state_id" IN
       (SELECT U0."id" AS Col1 FROM "patchwork_state" U0
                WHERE U0."action_required" = true
ORDER BY U0."ordering" ASC));

I think this is really slow because we have to join the patch and
submission table to get the project id, which we need to filter the
patches.

Duplicate the project id in the patch table itself, which allows us to
avoid the JOIN.

The new query reads as:
SELECT COUNT(*) AS "__count" FROM "patchwork_patch"
    WHERE ("patchwork_patch"."patch_project_id" = 1 AND
           "patchwork_patch"."state_id" IN
       (SELECT U0."id" AS Col1 FROM "patchwork_state" U0
        WHERE U0."action_required" = true
ORDER BY U0."ordering" ASC));

Very simple testing on a small, artifical Postgres instance (3
projects, 102711 patches), shows speed gains of ~1.5-5x for this
query. Looking at Postgres' cost estimates (EXPLAIN) of the first
query vs the second query, we see a ~1.75x improvement there too.

I suspect the gains will be bigger on OzLabs.

Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Daniel Axtens <dja@axtens.net>
7 years agoAdd validation for regular expressions
Veronika Kabatova [Fri, 16 Mar 2018 19:10:54 +0000 (20:10 +0100)] 
Add validation for regular expressions

Make sure entered regexes compile before saving them.

Signed-off-by: Veronika Kabatova <vkabatov@redhat.com>
Signed-off-by: Daniel Axtens <dja@axtens.net>
7 years agoAvoid timezone confusion
Veronika Kabatova [Thu, 22 Feb 2018 15:24:46 +0000 (16:24 +0100)] 
Avoid timezone confusion

Patchwork saves patches, comments etc with UTC timezone and reports
this time when opening the patch details. However, internally generated
processes such as events are reported with the instance's local time.
There's nothing wrong with that and making PW timezone-aware would add
useless complexity, but in a world-wide collaboration a lot of confusion
may arise as the timezone is not reported at all. Instance's local time
might be very different from the local time of CI integrating with PW,
which is different from the local time of person dealing with it etc.

Use UTC everywhere by default instead of UTC for sumbissions and local
timezone for internally generated events (which is not reported).

Signed-off-by: Veronika Kabatova <vkabatov@redhat.com>
[dja:
 - squash 2 patches: https://patchwork.ozlabs.org/patch/876744/
                     https://patchwork.ozlabs.org/patch/877815/
 - minor changes to both patches - rejig order of migrations and
   adjust wording: "happened sooner" -> "happened earlier"]
Tested-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: Daniel Axtens <dja@axtens.net>
7 years agoparser: don't fail on multiple SeriesReferences
Daniel Axtens [Mon, 19 Feb 2018 14:34:15 +0000 (01:34 +1100)] 
parser: don't fail on multiple SeriesReferences

Parallel parsing would occasonally fail with:

patchwork.models.MultipleObjectsReturned: get() returned more than one SeriesReference -- it returned 2!

I think these are happening if you have different processes parsing
e.g. 1/3 and 2/3 simultaneously: both will have a reference to 1/3,
in the case of 1 it will be the msgid, in the case of 2 it will be
in References. So when we come to parse 3/3, .get() finds 2 and
throws the exception.

This does not fix the creation of multiple series references; it
just causes them to be ignored. We still have serious race conditions
with series creation, but I don't yet have clear answers for them.
With this patch, they will at least not stop patches from being
processed - they'll just lead to wonky series, which we already have.

Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Signed-off-by: Daniel Axtens <dja@axtens.net>
7 years agoparser: use Patch.objects.create instead of save()
Daniel Axtens [Sun, 18 Feb 2018 01:57:03 +0000 (12:57 +1100)] 
parser: use Patch.objects.create instead of save()

Attempts to do parallel parsing with MySQL threw the following errors:

_mysql_exceptions.OperationalError: (1213, 'Deadlock found when trying to get lock; try restarting transaction')

Looking at the code, it was thrown when we created a patch like this:

patch = Patch(...)
patch.save()

The SQL statements that were being generated were weird:

UPDATE "patchwork_patch" SET ...
INSERT INTO "patchwork_patch" (...) VALUES (...)

As far as I can tell, the update could never work, because it was
trying to update a patch that didn't exist yet. My hypothesis is
that Django somehow didn't quite 'get' that because of the backend
complexity of the Patch model, so it tried to do an update, failed,
and then tried an insert.

Change the code to use Patch.objects.create, which makes the UPDATEs
and the weird MySQL errors go away.

Also move it up a bit earlier in the process so that if things go wrong
later at least we've committed the patch to the db.

Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
Signed-off-by: Daniel Axtens <dja@axtens.net>
7 years agoparser: avoid an unnecessary UPDATE of Person
Daniel Axtens [Sun, 18 Feb 2018 08:06:23 +0000 (19:06 +1100)] 
parser: avoid an unnecessary UPDATE of Person

Analysis of SQL statements showed that when parsing an email, the row
for the Person who sent the email was always getting updated. This is
because the test for updating it only checks if the incoming mail has
*a* name attached to the email address, and not if it has a new name.
Django is not smart enough to figure that out, and so unconditionally
UPDATEs the model when asked to save.

Give it a hand - only update the model and save it if the new name is
in fact different.

Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
Signed-off-by: Daniel Axtens <dja@axtens.net>
7 years agoparser: close a TOCTTOU bug on Person creation
Daniel Axtens [Sat, 17 Feb 2018 01:54:51 +0000 (12:54 +1100)] 
parser: close a TOCTTOU bug on Person creation

find_author looks up a person by email, and if they do not exist,
creates a Person model, which may be saved later if the message
contains something valuable.

Multiple simultaneous processes can race here: both can do the SELECT,
find there is no Person, and create the model. One will succeed in
saving, the other will get an IntegrityError.

Reduce the window by making find_author into get_or_create_author, and
plumb that through. (Remove a test that specifically required find_author
to *not* create).

More importantly, cover the case where we lose the race, by using
get_or_create which handles the race case, catching the IntegrityError
internally and fetching the winning Person model.

Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
[dja: post review cleanup of now-unused import]
Signed-off-by: Daniel Axtens <dja@axtens.net>
7 years agoparser: Handle even more exotically broken headers
Daniel Axtens [Mon, 19 Feb 2018 14:33:59 +0000 (01:33 +1100)] 
parser: Handle even more exotically broken headers

An archive of the Ubuntu kernel team mailing list contains a
fascinating email that causes the following parse error:

email.errors.HeaderParseError: header value appears to contain an embedded header:
  '4Mf^tnii7k\\_EnR5aobBm6Di[DZ9@AX1wJ"okBdX-UoJ>:SRn]c6DDU"qUIwfs98vF>...

The broken bit seem related to a UTF-8 quoted-printable encoded
section and to be from an internal attempt to break it over multiple
lines: here's a snippet from the error message:
    '\n\t=?utf-8?q?Tnf?=\n'
but interesting the header itself does not contain the new lines, so
clearly something quite weird is happening behind the scenes!

This only throws on header.encode(): it actually makes it through
sanitise_header and into find_headers before throwing the assertion.

So, try to encode in sanitize_header as a final step.

Also, fix a hilarious* python bug that this exposes: whitespace-only
headers cause an index error!

Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
Signed-off-by: Daniel Axtens <dja@axtens.net>
7 years agoAdd test for list filtering feature
Veronika Kabatova [Wed, 14 Feb 2018 13:34:29 +0000 (14:34 +0100)] 
Add test for list filtering feature

Signed-off-by: Veronika Kabatova <vkabatov@redhat.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
7 years agoImplement list filtering
Veronika Kabatova [Wed, 14 Feb 2018 13:34:28 +0000 (14:34 +0100)] 
Implement list filtering

Sometimes, multiple projects reside at the same mailing list. So far,
Patchwork only allowed a single project per mailing list, which made it
impossible for these projects to use Patchwork (unless they did some
dirty hacks).

Add a new property `subject_match` to projects and implement filtering
on (list_id, subject_match) match instead of solely list_id. Instance
admin can specify a regex on a per-project basis when the project is
created.

Signed-off-by: Veronika Kabatova <vkabatov@redhat.com>
Signed-off-by: Stephen Finucane <stephen@that.guru>
7 years agotools: drop vagrant
Daniel Axtens [Sat, 24 Feb 2018 01:22:54 +0000 (12:22 +1100)] 
tools: drop vagrant

It served us well, but it's now outdated (Trusty, Python 3.4, etc)
There is no indication that anyone uses it or keeps it up to date.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Acked-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
7 years agodocs: X-Patchwork-Ignore doesn't work, X-Patchwork-Hint: ignore does
Daniel Axtens [Thu, 22 Feb 2018 13:36:06 +0000 (00:36 +1100)] 
docs: X-Patchwork-Ignore doesn't work, X-Patchwork-Hint: ignore does

Make this match what is tested for in parser.py

Signed-off-by: Daniel Axtens <dja@axtens.net>
7 years agoDon't aim to have patchwork send email
Daniel Axtens [Thu, 15 Feb 2018 01:04:53 +0000 (12:04 +1100)] 
Don't aim to have patchwork send email

Getting things like SPF and DKIM right for this would be nigh-on
impossible, plus it would mean sysadmins would have to let patchwork
send email, which is a risk to the reputation of their systems.

Let's just aim for being a read-only representation of the mailing
list for now.

Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Signed-off-by: Daniel Axtens <dja@axtens.net>
7 years agorequirements: Use 'psycopg2-binary' package
Stephen Finucane [Fri, 9 Feb 2018 11:52:06 +0000 (11:52 +0000)] 
requirements: Use 'psycopg2-binary' package

This resolves a deprecation warning that's recently been raised:

  UserWarning: The psycopg2 wheel package will be renamed from release
  2.8; in order to keep installing from binary please use "pip install
  psycopg2-binary" instead. For details see:
  <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.

Signed-off-by: Stephen Finucane <stephen@that.guru>
7 years agomigrations: Add missing Series.Meta, Patch.Meta changes
Stephen Finucane [Fri, 9 Feb 2018 11:52:05 +0000 (11:52 +0000)] 
migrations: Add missing Series.Meta, Patch.Meta changes

These were missed in previous patches.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: 8585ea5af ("models: Use 'base_manager_name'")
Fixes: ed7328fdb ("models: Series plural name is Series")
7 years agoFix CRLF newlines upon submission changes
Veronika Kabatova [Wed, 7 Feb 2018 13:23:15 +0000 (14:23 +0100)] 
Fix CRLF newlines upon submission changes

After changing submission via admin interface, CRLF newlines are
suddenly present in the body. Replace them back to '\n'.

The issue was found after modifying submission via admin interface
using Python 2 and downloading the respective mbox file (git choked on
downloaded patch because of malformed line endings). Python 3's mail
module uses '\n' internally so the problem doesn't manifest there, but
the content received by Django/JS is still saved in the database with
CRLF line endings which shouldn't be there.

Signed-off-by: Veronika Kabatova <vkabatov@redhat.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
7 years agotravis: Run pep8 for py27 only
Stephen Finucane [Fri, 26 Jan 2018 21:47:51 +0000 (21:47 +0000)] 
travis: Run pep8 for py27 only

Keep run times to a minimum.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Acked-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: Daniel Axtens <dja@axtens.net>
7 years agoviews/user: string interpolation in raw SQL is safe here
Daniel Axtens [Mon, 29 Jan 2018 15:37:51 +0000 (02:37 +1100)] 
views/user: string interpolation in raw SQL is safe here

There's a FIXME asking for some generated SQL that uses string
interpolation to be investigated.

I investigated.

It's safe - it only interpolates table/column names, not
user-controlled data.

Replace the FIXME with an explanatory statement.

Signed-off-by: Daniel Axtens <dja@axtens.net>
7 years agoDon't create mailboxes/maildirs if not present
Daniel Axtens [Mon, 29 Jan 2018 15:24:46 +0000 (02:24 +1100)] 
Don't create mailboxes/maildirs if not present

I realised when I misspelled the name of an input to a test case
that mailbox will happily create an mbox or maildir if it doesn't
exist.

Don't do that, set create=False.

Signed-off-by: Daniel Axtens <dja@axtens.net>
7 years agoparser: allow series numbers at end of another prefix
Daniel Axtens [Mon, 29 Jan 2018 15:19:57 +0000 (02:19 +1100)] 
parser: allow series numbers at end of another prefix

We see some emails with e.g. "[PATCH1/8]" - no space between H and 1.

This is poor behaviour but we can accept it anyway.

Fixes: #126
Signed-off-by: Daniel Axtens <dja@axtens.net>
7 years agotags: be a bit more permissive in what we render to a message
Daniel Axtens [Thu, 25 Jan 2018 01:25:25 +0000 (12:25 +1100)] 
tags: be a bit more permissive in what we render to a message

Currently we render a tag from a comment into a message if it is

 '^(whatever)-by: .*'

We found a patch that had a UTF-8 non-breaking space after the colon,
and this was breaking the regex. So just remove the requirement for
a space entirely.

Closes: #124
Signed-off-by: Daniel Axtens <dja@axtens.net>
7 years agoparser: Fix parsing of pull request emails with CRLF line endings on Python 2
Andrew Donnellan [Mon, 8 Jan 2018 07:46:45 +0000 (18:46 +1100)] 
parser: Fix parsing of pull request emails with CRLF line endings on Python 2

When using Python 2, an incoming email that uses CRLF line endings won't
have the line endings converted by the email parser. This means that the
regex to detect pull request emails will fail to match.

Clean up the line endings when we extract the email body to fix this. (On
Python 3, the email parser policy fixes this for us at the initial email
parsing stage.)

Add a test pull request mbox with CRLF line endings to ensure we don't
regress.

Closes: #148 ("Parsing pull request emails broken on Python 2")
Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
[dja: fix up CRLF line endings munged by git-send-email
      renumber test
      re-order lines to put line-ending munging before other processing
      verify CRLF in file
      skip test if py3 for speed]
Signed-off-by: Daniel Axtens <dja@axtens.net>
7 years agoFix Python3.6 depreciation warnings
Daniel Axtens [Thu, 25 Jan 2018 02:43:17 +0000 (13:43 +1100)] 
Fix Python3.6 depreciation warnings

We see on Travis and on tox:
/home/travis/build/daxtens/patchwork/patchwork/tests/test_list.py:79: DeprecationWarning: invalid escape sequence \d
  id_re = re.compile('<tr id="patch_row:(\d+)"')
/home/travis/build/daxtens/patchwork/patchwork/tests/test_mail_settings.py:248: DeprecationWarning: invalid escape sequence \s
  form_re_template = ('<form\s+[^>]*action="%(url)s"[^>]*>'
/home/travis/build/daxtens/patchwork/patchwork/tests/test_parser.py:616: DeprecationWarning: invalid escape sequence \
  '\ No newline at end of file'))

All of these are easy to fix: just mark them as raw strings.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Stephen Finucane <stephen@that.guru>
7 years agodocker: add Python3.6 to image
Daniel Axtens [Thu, 25 Jan 2018 02:43:16 +0000 (13:43 +1100)] 
docker: add Python3.6 to image

This is needed to support py3.6-django111 in tox - otherwise tox
fails.

Python3.6 is not in Xenial, so this - irritatingly - requires pulling
in either a PPA, or the package from Artful. PPAs are icky, so pull it
in from Artful.

We can either add an Artful repo (like we do for Trusty to pull in
python3.4), or move the image to Artful and add in the Xenial repo
to get python3.5. It's more efficient to move the entire image to
Artful and pull in 3.5 from Xenial - otherwise most packages get
downloaded from Artful anyway. It does mean we're going to need to
move again to Bionic in a few months, but we'll just have to deal.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Stephen Finucane <stephen@that.guru>
7 years agotravis: test Python 3.6
Daniel Axtens [Thu, 25 Jan 2018 02:43:15 +0000 (13:43 +1100)] 
travis: test Python 3.6

We have a tox entry for py36-django111. We should test that in
Travis CI.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Stephen Finucane <stephen@that.guru>
7 years agotravis: run pep8/flake8 tests
Daniel Axtens [Thu, 25 Jan 2018 02:43:14 +0000 (13:43 +1100)] 
travis: run pep8/flake8 tests

Add the test at the end of each run. This is inefficient but simpler
than adding a matrix entry. It's also very fast so there's no slowdown.

While there, remove the 'codecov' package: tox will bring it in
automatically.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Stephen Finucane <stephen@that.guru>
7 years agoFix sy -> sys in pwclient error path
Daniel Axtens [Thu, 25 Jan 2018 02:43:12 +0000 (13:43 +1100)] 
Fix sy -> sys in pwclient error path

While running docker-compose run web --quick-tox, I got this
flake8/pep8 error for pwclient:

patchwork/bin/pwclient:713:9: F821 undefined name 'sy'

Fix by converting to 'sys' instead, which was intended.

Fixes: 58160097f957 ("pwclient: Resolve pycode warnings")
Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Stephen Finucane <stephen@that.guru>
7 years agopagination: Fix quirks
Daniel Axtens [Thu, 25 Jan 2018 02:43:11 +0000 (13:43 +1100)] 
pagination: Fix quirks

There are a couple of pages where the clickable list of pages
would include missing or duplicate pages.

Write a test that ensures:
 - you always have a link to the next/prev numbered page
 - there are no duplicate page numbers

Fiddle with the pagination algorithm to get it to pass - required
tweaking a display parameter and a couple of comparison operators,
so all pretty minor.

Now, if there are 10 pages, the displayed page numbers for a given
page are as follows:

Page # | Displayed page #s
---------------------------
1      | [] [1, 2, 3, 4] [9, 10]
2      | [] [1, 2, 3, 4] [9, 10]
3      | [] [1, 2, 3, 4] [9, 10]
4      | [1, 2] [3, 4, 5] [9, 10]
5      | [1, 2] [4, 5, 6] [9, 10]
6      | [1, 2] [5, 6, 7] [9, 10]
7      | [1, 2] [6, 7, 8] [9, 10]
8      | [1, 2] [7, 8, 9, 10] []
9      | [1, 2] [7, 8, 9, 10] []
10     | [1, 2] [7, 8, 9, 10] []

Closes: #102
Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Stephen Finucane <stephen@that.guru>
7 years agoparser: Handle 'git-request-pull' mails from Git 2.14.3
Stephen Finucane [Wed, 17 Jan 2018 19:39:36 +0000 (19:39 +0000)] 
parser: Handle 'git-request-pull' mails from Git 2.14.3

Make the regex case insensitive to catch both 'git' and 'Git'.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: #159
Reviewed-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
7 years agopwclient: Resolve pycode warnings
Stephen Finucane [Wed, 10 Jan 2018 09:42:51 +0000 (09:42 +0000)] 
pwclient: Resolve pycode warnings

Either catch the specific exceptions or, in two cases, remove
unnecessary error-handling code.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
7 years agoCorrect type (v2)
Stephen Finucane [Wed, 10 Jan 2018 09:36:08 +0000 (09:36 +0000)] 
Correct type (v2)

This is why you shouldn't do stuff at 1am.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: b891f8d ("parser: Log when invalid project list-id passed")
7 years agoCorrect typo
Stephen Finucane [Wed, 10 Jan 2018 00:45:31 +0000 (00:45 +0000)] 
Correct typo

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: b891f8d ("parser: Log when invalid project list-id passed")
7 years agoREST: Make single-use function a staticmethod
Stephen Finucane [Sat, 6 Jan 2018 22:43:56 +0000 (22:43 +0000)] 
REST: Make single-use function a staticmethod

Signed-off-by: Stephen Finucane <stephen@that.guru>
7 years agotrivial: Fix some nits
Stephen Finucane [Sat, 6 Jan 2018 23:50:20 +0000 (23:50 +0000)] 
trivial: Fix some nits

Signed-off-by: Stephen Finucane <stephen@that.guru>
7 years agoREST: Add 'mbox' to cover-letter response
Stephen Finucane [Wed, 20 Dec 2017 22:27:37 +0000 (22:27 +0000)] 
REST: Add 'mbox' to cover-letter response

This should have been here in the first place. Not sure why it was
missed.

Signed-off-by: Stephen Finucane <stephen@that.guru>
7 years agosignals: Don't call event creation code for fixtures
Stephen Finucane [Tue, 9 Jan 2018 21:47:28 +0000 (21:47 +0000)] 
signals: Don't call event creation code for fixtures

If loading fixtures via the 'loaddata' management command, then it is
unlikely that the signal handling code should execute. Disable it.

Signed-off-by: Stephen Finucane <stephen@that.guru>