Stephen Finucane [Fri, 13 Jan 2023 12:20:01 +0000 (12:20 +0000)]
Additional updates for compatibility with tox 4
'[tox] skipsdist' behaves differently in tox 4 [1]. In addition, setting
'[testenv] basepython' with '[tox] ignore_basepython_conflict' has been
the cause of a few tox 4 bugs (most since fixed, thankfully) and might
be deprecated [2]. Remove it since we don't need it in any of our
environments.
Ali Alnubani [Tue, 1 Aug 2023 08:15:35 +0000 (11:15 +0300)]
lib: add missing permissions for patchwork_covercomment_id_seq
Grants UPDATE and SELECT privileges on patchwork_covercomment_id_seq table
for user 'nobody' to fix the following exception when cover comments
are being parsed:
django.db.utils.ProgrammingError: permission denied for sequence
patchwork_covercomment_id_seq
Ali Alnubani [Mon, 31 Jul 2023 10:54:21 +0000 (13:54 +0300)]
lib: add missing permissions for patchwork_cover_id_seq
Grants UPDATE and SELECT privileges on patchwork_cover_id_seq table
for user 'nobody' to fix the following exception when cover letters
are being parsed:
django.db.utils.ProgrammingError: permission denied for sequence
patchwork_cover_id_seq
Ali Alnubani [Tue, 20 Jun 2023 11:06:07 +0000 (14:06 +0300)]
lib: add missing permissions for patchwork_comment_id_seq
Grants UPDATE and SELECT privileges on patchwork_comment_id_seq table
for web and mail users to fix the following exception when comments
are parsed:
django.db.utils.ProgrammingError: permission denied for sequence
patchwork_comment_id_seq
Fixes: 5b53f46def5f ("lib: fix table names") Signed-off-by: Ali Alnubani <alialnu@nvidia.com>
(cherry picked from commit f7bb805037d7d8710a0b025536616ef9cdfd4cef)
In commit 2653fdbb2, we started encoding slashes in message IDs
presented to users. This allowed us to support message IDs containing
slashes, which are allowed per the RFC and have been seen in the wild.
However, we continue to store the original unencoded message IDs in the
database and unfortunately we neglected to reverse the decoding in the
functions for downloading patch diffs and mboxes. Address this now.
Signed-off-by: Stephen Finucane <stephen@that.guru> Fixes: 2653fdbb2 ("urls: Encode slashes in message IDs") Closes: #518 Cc: Siddhesh Poyarekar <siddhesh@gotplt.org> Cc: DJ Delorie <dj@delorie.com>
(cherry picked from commit ddc4c7e41a7eaec5c08296d4b441c896324f86d4)
Stephen Finucane [Tue, 24 Jan 2023 23:31:22 +0000 (23:31 +0000)]
Correctly append tags on patches without commit details
Only a commit summary (a.k.a. patch subject) is necessary in Git: we
don't need details. The regex we were using to search for postscripts
however assumed that there would be _something_ before the postscript,
resulting in a newline. This wasn't the case. Correct this assumption by
instead using 're.MULTILINE' and matching on '^' and '$' for newlines
instead of '\n'.
Stephen Finucane [Wed, 11 May 2022 13:52:36 +0000 (14:52 +0100)]
urls: Encode slashes in message IDs
We were attempting to work around the fact that message IDs could
contain slashes which in some cases broke our ability to generate
meaningful URLs. Rather than doing this, insist that users encode these
slashes so that we can distinguish between semantically meaningful
slashes and those that form the URL. This is a slightly breaking change,
but the current behavior is already broken (see the linked bug) so this
seems reasonable.
Signed-off-by: Stephen Finucane <stephen@that.guru> Closes: #433 Cc: dja@axtens.net Cc: siddhesh@gotplt.org
(cherry picked from commit 2653fdbb2f33a9c762936ca97e3c6888b185cb4b)
Stephen Finucane [Fri, 15 Jul 2022 16:02:36 +0000 (17:02 +0100)]
docs: Bump API version in docs to 1.3
We also need to add missing API documentation pages for this new API
version. These should have been added in commit 5b03443c ("api: add
auto-generated OpenAPI schema files")
Signed-off-by: Stephen Finucane <stephen@that.guru>
Stephen Finucane [Wed, 11 May 2022 09:30:45 +0000 (10:30 +0100)]
parser: Handle binary git patches
'git-format-patch' is able to generate binary patches. Fortunately,
these are quite easy to spot since they're explicitly labelled as such.
Add support for parsing these to the parser.
Signed-off-by: Stephen Finucane <stephen@that.guru> Closes: #463
Ali Alnubani [Sun, 24 Apr 2022 20:59:35 +0000 (23:59 +0300)]
lib: fix table names
Migration 0042 (introduced in 0686a73) renamed the "Comment" model
to "PatchComment", and some of the table names changed in a51e7cf
were already correct.
This reverts a51e7cf and removes a nonexistent table name to resolve
the following error:
$ psql -f lib/sql/grant-all.postgres.sql DATABASE_NAME
BEGIN
psql:lib/sql/grant-all.postgres.sql:38: ERROR: relation
"patchwork_comment" does not exist
Fixes: a51e7cfd95e2 ("lib: Correct PatchComment table") Fixes: 7b967db4e12f ("lib: Update DB permissions to reflect model changes") Cc: stephen@that.guru Closes: #396 Signed-off-by: Ali Alnubani <alialnu@nvidia.com>
Amazingly, the only functional change required here is to add an
additional piece of code to re-enable shift-select [1]. This is
otherwise a straight swap.
We recently started stripping comments and folding white space from the
In-Reply-To and References headers. Do so also for the Message-ID
header. Because of the importance of the Message-ID header, we accept
even non-compliant headers and because we now have a pattern for this,
we also start (re-)accepting non-compliant In-Reply-To headers.
Signed-off-by: Stephen Finucane <stephen@that.guru>
Related: #399
parser: Ignore CFWS in In-Reply-To, References headers
RFC2822 states that [1] a comment or folding white space is permitted to
be inserted before or after a msg-id in in the Message-ID, In-Reply-To
or References fields. Allow for this.
Stephen Finucane [Tue, 14 Apr 2020 09:46:05 +0000 (10:46 +0100)]
REST: Include 'first', 'last' refs in 'Link' header
I've no idea why this wasn't done from day one, but it's a huge
usability win for anyone attempting to do pagination with this header.
Note that this change is not versioned as I haven't figured out how to
do that at this layer.
Signed-off-by: Stephen Finucane <stephen@that.guru>
This patch stitches in "comment created" events for patches and cover
letter into the event queue.
Signed-off-by: DJ Delorie <dj@redhat.com> Signed-off-by: Stephen Finucane <stephen@that.guru> Closes: #424
[stephenfin: Extend to cover letters also. Fix some formatting issues.
Add a release note]
Stephen Finucane [Fri, 25 Mar 2022 11:57:33 +0000 (11:57 +0000)]
docker: Further refine logic to apply migrations
We don't want to apply migrations by default since this will cause WIP
migrations to be applied if someone runs e.g. 'docker-compose run'. What
we really want to check is "are there any migrations currently applied?"
and skip if so, but Django doesn't provide an easy way to do this, so we
instead check for a random Django application.
Signed-off-by: Stephen Finucane <stephen@that.guru>
Stephen Finucane [Fri, 25 Mar 2022 09:30:08 +0000 (09:30 +0000)]
docker: Bump tested database versions
We were attempting to test with PostgreSQL 9.6, but Django 4.0 requires
PostgreSQL 10.0 or greater [1]. This was causing failures like those
seens at [2]. Configure jobs to use 'latest' like we do in CI to avoid
this issue.
While we're here, we also switch from MariaDB to MySQL and use the
'latest' tag of this. Once again, this was what we were actually using
in CI and doing this limits future work.
You-Sheng Yang [Thu, 9 Dec 2021 03:38:41 +0000 (11:38 +0800)]
docker: Drop database maintenance stuff
Trying to re-create database inside a client docker could be risky and
error prone.
1. The previous handling process may fail service startup when an empty
database was created. `test_database()` will always succeed as it tests
only the existence of the database, not any table inside. Without
migrations being called on such empty database, patchwork cannot work
normally.
2. Checking the existence of a patchwork specific table is also invalid
under the empty database scenario, because migrations might still remain
to be done.
As a result, we shall test if the database exist and do migrations
always, so this change removes database maintenance functions.
Signed-off-by: You-Sheng Yang <vicamo@gmail.com> Signed-off-by: Stephen Finucane <stephen@that.guru>
[stephenfin] Removed release note, since this is not end-user focused
You-Sheng Yang [Thu, 9 Dec 2021 03:38:39 +0000 (11:38 +0800)]
docker: Remove deprecated startup arguments
This also adds a default CMD directive so that it will launch a
patchwork instance when started with no argument.
Signed-off-by: You-Sheng Yang <vicamo@gmail.com> Signed-off-by: Stephen Finucane <stephen@that.guru>
[stephenfin] Removed release note, since this is not end-user focused
You-Sheng Yang [Sun, 12 Dec 2021 06:17:40 +0000 (14:17 +0800)]
docker: Rebase onto custom image
Rebuild pyenv environments can be time-consuming and irrelevant to this
project. Use a prebuild image to save some time here.
Signed-off-by: You-Sheng Yang <vicamo@gmail.com> Signed-off-by: Stephen Finucane <stephen@that.guru>
[stephenfin: Modified to use our own vendored image]
You-Sheng Yang [Sat, 27 Nov 2021 09:40:15 +0000 (17:40 +0800)]
ci: add docker-compose tests
Signed-off-by: You-Sheng Yang <vicamo@gmail.com> Signed-off-by: Stephen Finucane <stephen@that.guru>
[stephenfin: Removed release note, since this isn't user-facing]
Stephen Finucane [Fri, 19 Nov 2021 12:09:06 +0000 (12:09 +0000)]
Switch from Travis CI to GitHub Actions
Travis has imposed quotas on builds that require us to contact them to
obtain OSS credits. The CI tool is irrelevant so long as builds do
happen, so switch to GitHub Actions for now. This is a little more
complicated that the switch for related projects like git-pw, given the
need for a database service. We may wish to investigate reusing some of
our own Docker files in the future but for now, this should do the
trick.
Signed-off-by: Stephen Finucane <stephen@that.guru>
Stephen Finucane [Thu, 26 Aug 2021 17:18:31 +0000 (18:18 +0100)]
tests: Tweak comment API tests
We were missing tests for 'GET /patch/{patch_id}/comment' (list patch
comments) and 'GET /cover/{cover_id}/comment' (list cover comments) when
using API version 1.2. In addition, we had effectively duplicated tests
by including explicit tests for API 1.3. These are unnecessary since we
default to testing against the latest version. Address both issues.
Signed-off-by: Stephen Finucane <stephen@that.guru>
Stephen Finucane [Thu, 26 Aug 2021 17:18:28 +0000 (18:18 +0100)]
Make addressed/unaddressed workflow opt-in
The current workflow for the address/unaddressed attribute of comments
sets all comments to unaddressed by default. This is unintuitive, as it
assumes that all comments are actionable items. It also imposes a
massive burden on maintainers, who will need to manually sift through
every single comment received to a list and manually set the
non-actionable items as "addressed".
Change this workflow so that the 'addressed' field defaults to NULL.
This means maintainers or users must manually set this to False when
they're requesting additional feedback. This is currently possible via
the web UI or REST API. A future change will make it possible via a
custom mail header.
Signed-off-by: Stephen Finucane <stephen@that.guru> Cc: Raxel Gutierrez <raxel@google.com> Cc: Daniel Axtens <dja@axtens.net>
Stephen Finucane [Thu, 28 Oct 2021 10:38:41 +0000 (11:38 +0100)]
requirements: Pin jsonschema
The new 4.x release of jsonschema has borked our schemas for reasons I
do not yet fully understand (though I have an idea - see inline). Unbork
things now and fix our CI, while we work on a longer-term fix.
Signed-off-by: Stephen Finucane <stephen@that.guru>
Stephen Finucane [Wed, 29 Sep 2021 14:53:04 +0000 (15:53 +0100)]
tox: Use compatible minor releases
As we previously did for the requirements files (commit c90473ea44),
switch to use compatible releases for tox. We previously avoided doing
this on the basis that the existing system gave an idea of supported
package versions, but we weren't actually testing these combinations
since pip will always install the latest available version of each
package. This will apply to anyone using pip to manage their
dependencies, while anyone using distro packages can rely on the distro
having done this testing for them. Given the above, this makes our
effort to track supported ranges moot. So long as we cap newer versions
of e.g. django-filter when they're not compatible with older Django
versions, we should be good.
Signed-off-by: Stephen Finucane <stephen@that.guru>
Stephen Finucane [Wed, 29 Sep 2021 14:44:04 +0000 (15:44 +0100)]
requirements: Bump Django to 3.2.x, django-filter to 21.1
It seems the ORM is now smarter and requires less JOINs that previously
in two tests. In addition, a new setting is required to ensure the type
of our primary field columns doesn't change when Django 4.0 is released.
We drop support for Django 3.1 in the process, though this doesn't have
much of a real-world impact since we still support Django 2.2, an LTS
release.
Signed-off-by: Stephen Finucane <stephen@that.guru>
Stephen Finucane [Tue, 28 Sep 2021 10:52:29 +0000 (11:52 +0100)]
Revert "docs: prevent build error by rolling back Sphinx version"
This reverts commit 65547c8701004f1a2a9ed9d16f1a372f4bd856e4. There is a
new release of sphinxcontrib-httpdomain [1] that fixes the issues with
Sphinx 4.1.x and later [2]
Signed-off-by: Stephen Finucane <stephen@that.guru> Cc: Daniel Axtens <dja@axtens.net>
[dja: change badge url to get users from the PW discord, not another
mystery discord. Also, enable the PW discord to report its status
via badges.] Signed-off-by: Daniel Axtens <dja@axtens.net>
Raxel Gutierrez [Fri, 20 Aug 2021 04:50:29 +0000 (04:50 +0000)]
patch-detail: add label and button for comment addressed status
Add new label to patch and cover comments to show the status of whether
they are addressed or not and add an adjacent button to allow users to
change the status of the comment. Only users that can edit the patch
(i.e. patch author, delegate, project maintainers) as well as comment
authors can change the status of a patch comment. For cover comments,
there are no delegates, so only maintainers and cover/cover comment
authors can edit the status of the cover comment. Before [1] and after
[2] images for reference.
Use new comment detail REST API endpoint to update the addressed field
value when "Addressed" or "Unaddressed" buttons are clicked. After a
successful request is made, the appearance of the comment status label
and buttons are toggled appropriately. For unsuccessful requests (e.g.
network errors prevents reaching the server), the error message is
populated to the page. A future improvement on this behavior is to add
a spinner to the button to provide a feedback that the request is in a
pending state until it's handled.
Raxel Gutierrez [Fri, 20 Aug 2021 04:50:27 +0000 (04:50 +0000)]
api: add comments detail endpoint
Add new endpoint for patch and cover comments at api/.../comments/<comment_id>.
This involves updating the API version to v1.3 to reflect the new
endpoints as a minor change, following the usual semantic versioning
convention.
The endpoint will make it possible to use the REST API to update the new
`addressed` field for individual patch and cover comments with JavaScript
on the client side. In the process of these changes, clean up the use of
the CurrentPatchDefault context so that it exists in base.py and can be
used throughout the API (e.g. Check and Comment REST endpoints).
The tests cover retrieval and update requests and also handle calls from
the various API versions. Also, they cover permissions for update
requests and handle invalid update values for the new `addressed` field.
Signed-off-by: Raxel Gutierrez <raxel@google.com>
[dja: changes to not conflict with, and to adopt the changes in, fecf7c86c2c5
various other minor changes as described on list] Signed-off-by: Daniel Axtens <dja@axtens.net>
Raxel Gutierrez [Fri, 20 Aug 2021 04:50:26 +0000 (04:50 +0000)]
models: change edit permissions for comments
Change patch comments' edit permissions to match that of the patch
associated with the comment (i.e. patch author, project maintainers, and
delegate) and add permissions for both patch and cover comment authors
to be able to change the `addressed` status of comments as well. For
cover comments, add permissions to edit for cover submitter and project
maintainers.
Signed-off-by: Raxel Gutierrez <raxel@google.com> Signed-off-by: Daniel Axtens <dja@axtens.net>
Raxel Gutierrez [Fri, 20 Aug 2021 04:50:25 +0000 (04:50 +0000)]
models: add addressed field
Currently, there is no state or status associated with comments. In
particular, knowing whether a comment on a patch or cover letter is
addressed or not is useful for transparency and accountability in the
patch review and contribution process. This patch is backend setup for
tracking the state of patch and cover comments.
Add `addressed` boolean field to patch and cover comments to be able to
distinguish between unaddressed and addressed comments in the
patch-detail page.
Signed-off-by: Raxel Gutierrez <raxel@google.com> Reviewed-by: Daniel Axtens <dja@axtens.net>
[dja: give the migration a more meaningful name] Signed-off-by: Daniel Axtens <dja@axtens.net>
Raxel Gutierrez [Fri, 20 Aug 2021 04:50:24 +0000 (04:50 +0000)]
templatetags: add utils template filters and tags
Add utils.py file to create template filters and tags that can be used
by most if not all objects in Patchwork. In particular, add a template
filter to get the plural verbose name of a model and add a template tag
that returns whether an object is editable by the current user. These
utilities will be used in an upcoming patch that adds the `addressed`
status label to patch and cover comments.
Signed-off-by: Raxel Gutierrez <raxel@google.com> Reviewed-by: Stephen Finucane <stephen@that.guru> Signed-off-by: Daniel Axtens <dja@axtens.net>
Raxel Gutierrez [Fri, 20 Aug 2021 04:50:23 +0000 (04:50 +0000)]
api: change <pk> parameter to <cover_id> for cover comments endpoint
Rename cover lookup parameter `pk` to `cover_id` for the cover comments
list endpoints to disambiguate from the lookup parameter `comment_id` in
upcoming patches which introduces the cover comments detail endpoint.
This doesn't affect the user-facing API.
Signed-off-by: Raxel Gutierrez <raxel@google.com> Reviewed-by: Stephen Finucane <stephen@that.guru>
[dja: fixup to apply on top of fecf7c86c2c5 and 0ed2feb26c84] Signed-off-by: Daniel Axtens <dja@axtens.net>