]> git.ipfire.org Git - thirdparty/patchwork.git/commit
REST: Add patch relations
authorMete Polat <metepolat2000@gmail.com>
Thu, 27 Feb 2020 23:29:32 +0000 (23:29 +0000)
committerDaniel Axtens <dja@axtens.net>
Mon, 16 Mar 2020 00:15:57 +0000 (11:15 +1100)
commit83f364aad66c35e31df8d0871ec2b62016eba337
tree9a9c650ec0e11f18ca5b25145ec64ae9689ba378
parent27c2acf56cd30e77c932a1dde87b6fc1de8eeb2c
REST: Add patch relations

View relations and add/update/delete them as a maintainer. Maintainers
can only create relations of patches which are part of a project they
maintain. Because this is a writable many-many nested relationship, it
behaves a little unusually. In short:

- All operations use PATCH to the 'related' field of a patch

- To relate a patch to another patch, say 7 to 19, either:

    PATCH /api/patch/7  related := [19]
    PATCH /api/patch/19 related := [7]

- To delete a patch from a relation, say 1, 21 and 42 are related but we
  only want it to be 1 and 42:

    PATCH /api/patch/21 related := []

  * You _cannot_ remove a patch from a relation by patching another
    patch in the relation: I'm trying to avoid read-modify-write loops.

  * Relations that would be left with just 1 patch are deleted. This is
    only ensured in the API - the admin interface will let you do this.

- Break-before-make: if you have [1, 12, 24] and [7, 15, 42] and you want
  to end up with [1, 12, 15, 42], you have to remove 15 from the second
  relation first:

    PATCH /api/patch/1 related := [15] will fail with 409 Conflict.

  Instead do:

    PATCH /api/patch/15 related := []
    PATCH /api/patch/1  related := [15]
       -> 200 OK, [1, 12, 15, 42] and [7, 42] are the resulting relations

Signed-off-by: Mete Polat <metepolat2000@gmail.com>
Signed-off-by: Stephen Finucane <stephen@that.guru>
Signed-off-by: Daniel Axtens <dja@axtens.net>
docs/api/schemas/latest/patchwork.yaml
docs/api/schemas/patchwork.j2
docs/api/schemas/v1.1/patchwork.yaml
docs/api/schemas/v1.2/patchwork.yaml
patchwork/api/embedded.py
patchwork/api/event.py
patchwork/api/patch.py
patchwork/tests/api/test_patch.py
patchwork/tests/api/test_relation.py [new file with mode: 0644]
patchwork/tests/utils.py
releasenotes/notes/add-patch-relations-c96bb6c567b416d8.yaml [new file with mode: 0644]