forked from vhaudiquet/rhema-claw
fix(forge,claw): forge keys separate the issue from the pull
The watch key encoded source, repo, and number but not the thread
kind, and on GitLab an issue and a merge request share one number
space: iid 7 twice produced one key, one snapshot, and comments on
the merge request landing in the issue (or a 404 fallback that
misrouted the other way). The key carries the kind now —
{source}:{kind}:{owner}/{name}#{number}, with GitLab spelling the
pull variant mr — comment and snapshot route outright by kind, and a
kind-less payload parses to the unparsable key instead of guessing
issue. The claw's callers thread the kind from the payload and strip
the segment where the bare repo is wanted; pre-kind stored keys parse
as None rather than misroute. Four route-pinning wiremock tests cover
the GitLab split, and the GitHub/Gitea clients take the kind without
using it (their issues and PRs share the same REST space).
This commit is contained in:
1 parent
10efe85f38
commit
00adf092ff
15 files changed
+478
-178
No files matched your search
@@ -16,7 +16,7 @@
|
||||
use async_trait::async_trait;
|
||||
|
||||
use crate::error::ForgeError;
|
||||
use crate::event::{ForgeEvent, NotificationPage, RepoRef, Snapshot, Timestamp};
|
||||
use crate::event::{ForgeEvent, ForgeThreadKind, NotificationPage, RepoRef, Snapshot, Timestamp};
|
||||
|
||||
/// One poll's worth of activity, with the cursor to continue from.
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
@@ -61,12 +61,33 @@ pub trait Forge: Send + Sync {
|
||||
since: Option<&Timestamp>,
|
||||
) -> Result<ForgePage, ForgeError>;
|
||||
|
||||
/// Posts `body` as a new comment on thread `number`.
|
||||
async fn comment(&self, repo: &RepoRef, number: u64, body: &str) -> Result<(), ForgeError>;
|
||||
/// Posts `body` as a new comment on the thread `kind` + `number`
|
||||
/// name.
|
||||
///
|
||||
/// On GitLab the kind picks the sequence the iid is read against:
|
||||
/// issues and merge requests are numbered independently, and only
|
||||
/// the named one is addressed — a miss surfaces as a 404, never a
|
||||
/// silent post to the other sequence. GitHub and Gitea share one
|
||||
/// number space across issues and pull requests (every pull request
|
||||
/// is an issue there), so they accept the kind for signature
|
||||
/// uniformity and either value addresses the same thread.
|
||||
async fn comment(
|
||||
&self,
|
||||
repo: &RepoRef,
|
||||
kind: ForgeThreadKind,
|
||||
number: u64,
|
||||
body: &str,
|
||||
) -> Result<(), ForgeError>;
|
||||
|
||||
/// The thread's current state, so a handler can orient without a
|
||||
/// second API round-trip.
|
||||
async fn snapshot(&self, repo: &RepoRef, number: u64) -> Result<Snapshot, ForgeError>;
|
||||
/// second API round-trip. `kind` selects the sequence `number` is
|
||||
/// read against, under the same rules as [`Forge::comment`].
|
||||
async fn snapshot(
|
||||
&self,
|
||||
repo: &RepoRef,
|
||||
kind: ForgeThreadKind,
|
||||
number: u64,
|
||||
) -> Result<Snapshot, ForgeError>;
|
||||
|
||||
/// The account's notification feed: everything addressed to the
|
||||
/// account this client authenticates as, across every repository it
|
||||
|
||||
Reference in new issue
Block a user