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
@@ -41,8 +41,8 @@ use serde_json::Value;
|
||||
|
||||
use crate::error::{ForgeError, ensure_success, required};
|
||||
use crate::event::{
|
||||
EventKind, ForgeEvent, Notification, NotificationPage, NotificationReason, RepoRef, Snapshot,
|
||||
ThreadState, Timestamp,
|
||||
EventKind, ForgeEvent, ForgeThreadKind, Notification, NotificationPage, NotificationReason,
|
||||
RepoRef, Snapshot, ThreadState, Timestamp,
|
||||
};
|
||||
use crate::forge::{Forge, ForgePage};
|
||||
|
||||
@@ -620,8 +620,18 @@ impl Forge for GitHubForge {
|
||||
Ok(ForgePage::finish(events, since))
|
||||
}
|
||||
|
||||
async fn comment(&self, repo: &RepoRef, number: u64, body: &str) -> Result<(), ForgeError> {
|
||||
async fn comment(
|
||||
&self,
|
||||
repo: &RepoRef,
|
||||
_kind: ForgeThreadKind,
|
||||
number: u64,
|
||||
body: &str,
|
||||
) -> Result<(), ForgeError> {
|
||||
// The issues endpoint covers PRs too: every PR is an issue here.
|
||||
// Issues and pull requests share one number space, so `_kind`
|
||||
// cannot change the route — either value addresses the same
|
||||
// thread, and the parameter exists only for the trait's uniform
|
||||
// signature (GitLab is the forge whose sequences differ).
|
||||
let path = format!(
|
||||
"/repos/{}/{}/issues/{number}/comments",
|
||||
repo.owner, repo.name
|
||||
@@ -636,7 +646,14 @@ impl Forge for GitHubForge {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn snapshot(&self, repo: &RepoRef, number: u64) -> Result<Snapshot, ForgeError> {
|
||||
async fn snapshot(
|
||||
&self,
|
||||
repo: &RepoRef,
|
||||
_kind: ForgeThreadKind,
|
||||
number: u64,
|
||||
) -> Result<Snapshot, ForgeError> {
|
||||
// One number space across issues and pulls: `_kind` cannot
|
||||
// change the route (see `comment`).
|
||||
let issue_path = format!("/repos/{}/{}/issues/{number}", repo.owner, repo.name);
|
||||
let response = self
|
||||
.get(&issue_path)
|
||||
|
||||
Reference in new issue
Block a user