Commit Graph

251 Commits (master)

Author SHA1 Message Date
Adnan Maolood 8deee3476d Move go.mod to root 2023-06-01 12:27:24 +02:00
Adnan Maolood c4e50c633e hubsrht: Use repository visibility for builds 2023-04-19 09:22:20 +02:00
Drew DeVault f362bd8835 Upgrade to Alpine 3.17 2023-03-22 12:17:05 +01:00
Vlad-Stefan Harbuz fb56d7ba60 add project RSS feed
Signed-off-by: Vlad-Stefan Harbuz <vlad@vladh.net>
2023-02-22 09:18:52 +01:00
Conrad Hoffmann fce16cc33e Use uppercase string for icon in patchset update
In GraphQL, the icon has to be uppercase [1]. However, the builds worker
uses the `JobContext.Job.Status` field in the payload [2], where the
value is lowercase [3]. Hence, upper-case the value before sending it to
the GraphQL API.

[1] https://git.sr.ht/~sircmpwn/lists.sr.ht/tree/master/item/api/graph/schema.graphqls#L468-474
[2] https://git.sr.ht/~sircmpwn/builds.sr.ht/tree/master/item/worker/triggers.go#L251
[3] https://git.sr.ht/~sircmpwn/builds.sr.ht/tree/master/item/worker/triggers.go#L109
2022-12-02 12:27:38 +01:00
Conrad Hoffmann ec7a552ffc webhooks: add error handling for patch submission
Currently, any 400 error that occurs will be swallowed by
`SrhtService.post()` [1] - the caller must use a validation object to
become aware of an error.

This commit adds such error handling by means of a validation object to
the build submission webhook.

[1]: https://git.sr.ht/~sircmpwn/hub.sr.ht/tree/f37b9e6e/item/hubsrht/services.py#L56-60
2022-11-25 10:24:17 +01:00
Drew DeVault f37b9e6e18 Update patchset build submission to use GQL API 2022-11-09 11:53:43 +01:00
Adnan Maolood e2dbb6c316 API: implement user account deletion 2022-11-02 11:57:24 +01:00
Adnan Maolood 0f2393ea80 hubsrht: Use canonical user IDs
Update user IDs across all of hub.sr.ht to match those of meta.sr.ht.
2022-10-25 11:00:27 +02:00
Adnan Maolood 638a05c8df hubsrht: Expect valid canonical name in URLs 2022-09-06 15:39:24 +02:00
Adnan Maolood 2f890ff9d3 Add schema.sql 2022-08-17 10:06:27 +02:00
Simon Ser 820b86cf9a Handle Closes commit trailers
References: c4bfcd1ff7
2022-07-26 13:43:56 +02:00
Adnan Maolood 16dea8ac4d hubsrht: Match projects case-sensitively 2022-07-06 10:29:31 +02:00
Conrad Hoffmann d637723564 Uppercase the Visibility enum keys
There is currently a mismatch, causing for example project creation via
the web interface to fail, because the validation code is using the enum
keys, which are lowercase, but everything else uses uppercase.

Simply use uppercase everywhere, like already the case in other
services.
2022-07-01 09:18:57 +02:00
Adnan Maolood 7e78dc04d9 hubsrht/blueprints/sources: Fix visibility 2022-06-29 18:05:26 +02:00
Adnan Maolood 4e4f17770b hubsrht/blueprints/webhooks: Fix visibility 2022-06-29 18:05:26 +02:00
Drew DeVault c53d26260f Fix up previous migration 2022-06-29 17:40:59 +02:00
Adnan Maolood ab821d423a hubsrht: Add visibility enum 2022-06-29 17:22:53 +02:00
Adnan Maolood db74624e2a hubsrht: Use User.tracker instead of trackerByOwner 2022-04-29 11:10:37 +02:00
Drew DeVault d292f65f1f projects: remember visibility across form submissions
References: https://lists.sr.ht/~sircmpwn/sr.ht-discuss/%3CCJ5SEF4HBSQ5.2N6Y2AG1CUDQZ%40arctic%3E
2022-04-11 12:16:21 +02:00
Drew DeVault 45a2f75b8b webhooks: prevent error on new/removed git refs 2022-03-21 10:28:10 +01:00
Conrad Hoffmann d52edefe18 Avoid adding lists to project multiple times
If a list exists already it might also already be connected to the
project. If that is the case, simply skip processing this list.

Fixes: https://todo.sr.ht/~sircmpwn/hub.sr.ht/83
2022-03-14 12:55:29 +01:00
Eyal Sawady 38292b8bea .builds/alpine.yml: upgrade to 3.15 2022-02-28 11:14:25 +01:00
Robin Jarry 1b33a612d1 webhooks: avoid duplicate todo comments
When pushing a tag, the webhooks are invoked twice: once for the the
commit and once for the tag. Avoid inserting the same comment multiple
times. This also fixes the multiple comments issue when a git repository
is associated with more than one project.

This requires the new graphql method to get specific tickets by their
scoped ID on a given tracker.

Signed-off-by: Robin Jarry <robin@jarry.cc>
2022-02-21 11:51:37 +01:00
Adnan Maolood 800aa59bda hubsrht/services: Fix log query (again) 2022-02-14 19:02:09 +01:00
Adnan Maolood 91146b1a15 hubsrht/services: Use api-origin where necessary 2022-02-14 19:02:09 +01:00
Adnan Maolood 7e41182f56 hubsrht/services: Fix log query 2022-02-14 18:17:02 +01:00
Adnan Maolood 9c3aca190b hubsrht/services: Fall back to origin if api-origin is unset 2022-02-14 18:16:59 +01:00
Drew DeVault b2e5433d30 projects.py: print readme exceptions 2022-02-14 17:53:23 +01:00
Adnan Maolood 43604cea9b hubsrht/services: Use api-origin for GraphQL queries
Use api-origin instead of origin for GraphQL queries, as these are not
necessarily the same.
2022-02-14 15:42:52 +01:00
Adnan Maolood a77998c012 hubsrht: Remove usage of repository(id) GraphQL query
The repository(id) query will be removed from git.sr.ht, so use the
User.repository(name) query instead.
2022-02-14 15:42:51 +01:00
Galen Abell 34c5650cd8 webhooks: Don't fail if there is no todo.sr.ht 2021-12-13 10:23:07 +01:00
наб ed74fc06c4 project-nav.html: add visibility tag like in git., todo., &c. 2021-12-08 18:24:45 +01:00
Peter Sanchez 14e4867dd3 Updating config example for new mail options 2021-12-01 09:18:35 +01:00
Robin Jarry b5ebc44032 webhooks/git: use markdown for tracker comments
The raw body of comments is included in email notifications. HTML makes
ugly plain text messages.

Use markdown for generated tracker comments which can be used in plain
text emails as-is.

Fixes: https://todo.sr.ht/~sircmpwn/hub.sr.ht/77
Fixes: be5d50d8d8 ("webhooks: update todo tickets with git commits")
Signed-off-by: Robin Jarry <robin@jarry.cc>
2021-11-29 14:57:27 +01:00
Robin Jarry be5d50d8d8 webhooks: update todo tickets with git commits
Allow referencing tracker tickets in git commit messages via specific
trailer words:

  Fixes: <ticket url>
  Implements: <ticket url>
  References: <ticket url>

These must follow standard git trailer syntax. The trailers are
extracted from commit messages with the function added in previous
commit. The ticket url must point to a valid ticket.

A comment will be inserted in the ticket with a back reference to the
git commit and its original author. The comment will be made by the user
who pushed the commit. E.g.:

  ~arkanoid REPORTED -> FIXED                          9 seconds ago

  John Doe referenced this ticket in commit b4dc4c40.

Open tickets referenced by a Fixes trailer will be resolved with the
FIXED resolution.

Open tickets referenced by an Implements trailer will be resolved with
the IMPLEMENTED resolution.

Caveats:

* Only the 25 most recent commit messages will be considered when
  pushing long series. This should be a fairly sane limitation.

* If the user pushing commits does not have triage/comment permissions
  on the bug tracker, nothing will happen.

* Invalid/non-existent ticket urls are ignored.

* When a git repository is part of more than one project, the webhook
  will run once per project and update the same ticket(s) once per
  project as well.

* If an already resolved ticket is referenced by a Fixes or Implements
  trailer, only a comment will be added.

Link: https://git-scm.com/docs/git-interpret-trailers
Implements: https://todo.sr.ht/~sircmpwn/hub.sr.ht/55
Signed-off-by: Robin Jarry <robin@jarry.cc>
2021-11-29 10:52:32 +01:00
Robin Jarry a9f72b5a59 git: add function to parse message trailers
This is a pure python implementation of the message trailer parsing
algorithm in git (and libgit2). It is intended for use on finalized
commit messages only. Lines starting with comments are not ignored.

The function returns a list of pairs (name, value) where name is the
name of the trailer. Trailer values may span over multiple lines.

Link: https://git-scm.com/docs/git-interpret-trailers
Link: https://github.com/git/git/blob/master/trailer.c
Link: https://github.com/libgit2/libgit2/blob/main/src/trailer.c
Signed-off-by: Robin Jarry <robin@jarry.cc>
2021-11-29 10:52:31 +01:00
Drew DeVault 060b91237b Remove popular tags 2021-11-28 11:26:59 +01:00
Drew DeVault c34944b943 trackers: configure with visibility
Following the introduction of visibility parameters to todo.sr.ht.

Fixes ~sircmpwn/hub.sr.ht#75
2021-10-29 10:55:05 +02:00
Drew DeVault 48aadb5b1c Correct syntax error in previous change
I would have sworn that I had tested that.
2021-10-06 10:06:51 +02:00
Drew DeVault af1c1b3797 Fixes per lists.sr.ht updates 2021-10-06 10:02:14 +02:00
Drew DeVault fcddddef7a Handle null response from createRepository 2021-09-24 10:05:32 +02:00
Sebastian LaVine 809792c0d0 Remove misplaced word 2021-09-21 09:20:43 +02:00
Drew DeVault caae0b5aa6 webhooks: handle trackers on multiple projects 2021-08-30 14:44:48 +02:00
Drew DeVault 207a992905 webhooks: fix unbound variable
Missed this one in a previous commit.
2021-08-23 16:59:57 +02:00
Drew DeVault 6fb2029120 webhooks: handle git repos on multiple projects
It is possible for one git repository to be added to several hub
projects, but the webhook was not prepared for this case.
2021-08-23 11:24:03 +02:00
Daniel P 590f5dc1f3 Remove whitespace after project description 2021-08-23 10:13:32 +02:00
Drew DeVault 84710264d5 Fetch existing resources for sources, trackers
This is a generalization of the previous bug fix.
2021-08-12 08:21:29 +02:00
Sol Fisher Romanoff 1426569187 Make project names match [A-Za-z0-9._-]+
Project names in URLs are now case-insensitive --
This might break existing projects.

Also prohibits use of '.git' and '.hg' as project names.
2021-08-11 09:41:50 +02:00
Drew DeVault 9add0bfac7 mailing lists: fetch lists on validation error
This fixes a crash which would occur if you had a validation error in
your form submission.
2021-08-09 09:06:51 +02:00