Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ba258a1f50 | ||
|
|
e4244f02d8 |
No files matched your search
@@ -26,8 +26,7 @@ use rhema_autonomous_agent::{Source, SourceError, async_trait};
|
|||||||
use rhema_forge_integration::forge_key_fn;
|
use rhema_forge_integration::forge_key_fn;
|
||||||
use rhema_forge_integration::triage::{self, Triage};
|
use rhema_forge_integration::triage::{self, Triage};
|
||||||
use rhema_forge_integration::{
|
use rhema_forge_integration::{
|
||||||
Forge, GitHubForge, GitLabForge, GiteaForge, Notification, RepoRef, Timestamp, Watcher,
|
Forge, GitHubForge, GitLabForge, GiteaForge, Notification, Timestamp, Watcher, register_forge,
|
||||||
register_forge,
|
|
||||||
};
|
};
|
||||||
use rhema_identity::{IdentityStore, SecretKind};
|
use rhema_identity::{IdentityStore, SecretKind};
|
||||||
use rhema_rsd::{Clock, Dispatcher, Event, KeyFn, SystemClock};
|
use rhema_rsd::{Clock, Dispatcher, Event, KeyFn, SystemClock};
|
||||||
@@ -391,7 +390,7 @@ impl ForgeSource {
|
|||||||
if let Some(since) = stored.as_deref().and_then(Timestamp::parse) {
|
if let Some(since) = stored.as_deref().and_then(Timestamp::parse) {
|
||||||
return Ok(since);
|
return Ok(since);
|
||||||
}
|
}
|
||||||
let now = Timestamp::from_epoch_millis(SystemClock.now_millis() as i64)
|
let now = Timestamp::from_epoch_millis(SystemClock.now_millis())
|
||||||
.ok_or_else(|| SourceError::Backend("cannot spell this instant".to_owned()))?;
|
.ok_or_else(|| SourceError::Backend("cannot spell this instant".to_owned()))?;
|
||||||
self.store
|
self.store
|
||||||
.set_cursor(SCOPE_REPO, &record.forge, &record.repo, now.raw())
|
.set_cursor(SCOPE_REPO, &record.forge, &record.repo, now.raw())
|
||||||
@@ -620,7 +619,13 @@ mod tests {
|
|||||||
.add("gitea", "acme/barn", Some(&server.uri()), "tok")
|
.add("gitea", "acme/barn", Some(&server.uri()), "tok")
|
||||||
.expect("add");
|
.expect("add");
|
||||||
let (dispatcher, accounts, notifications) = test_parts(store.clone());
|
let (dispatcher, accounts, notifications) = test_parts(store.clone());
|
||||||
let source = ForgeSource::new(&dispatcher, "gitea", store.clone(), accounts, notifications);
|
let source = ForgeSource::new(
|
||||||
|
&dispatcher,
|
||||||
|
"gitea",
|
||||||
|
store.clone(),
|
||||||
|
accounts,
|
||||||
|
notifications,
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
source.detect().await.expect("the pass runs"),
|
source.detect().await.expect("the pass runs"),
|
||||||
@@ -662,9 +667,7 @@ mod tests {
|
|||||||
Some(cursor)
|
Some(cursor)
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
store
|
store.health(SCOPE_REPO, "gitea", "acme/barn").expect("health reads")
|
||||||
.health(SCOPE_REPO, "gitea", "acme/barn")
|
|
||||||
.expect("health reads")
|
|
||||||
.map(|health| health.consecutive_failures),
|
.map(|health| health.consecutive_failures),
|
||||||
Some(0),
|
Some(0),
|
||||||
"the watch polled cleanly"
|
"the watch polled cleanly"
|
||||||
|
|||||||
@@ -703,9 +703,7 @@ mod tests {
|
|||||||
fn a_cursor_is_kept_per_watch_and_moves_forward() {
|
fn a_cursor_is_kept_per_watch_and_moves_forward() {
|
||||||
let store = ClawStore::in_memory().expect("store opens");
|
let store = ClawStore::in_memory().expect("store opens");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
store
|
store.cursor(SCOPE_REPO, "gitea", "acme/barn").expect("read"),
|
||||||
.cursor(SCOPE_REPO, "gitea", "acme/barn")
|
|
||||||
.expect("read"),
|
|
||||||
None,
|
None,
|
||||||
"a watch that never polled has no cursor"
|
"a watch that never polled has no cursor"
|
||||||
);
|
);
|
||||||
@@ -714,16 +712,12 @@ mod tests {
|
|||||||
.set_cursor(SCOPE_REPO, "gitea", "acme/barn", "2026-10-08T00:00:00Z")
|
.set_cursor(SCOPE_REPO, "gitea", "acme/barn", "2026-10-08T00:00:00Z")
|
||||||
.expect("cursor lands");
|
.expect("cursor lands");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
store
|
store.cursor(SCOPE_REPO, "gitea", "acme/barn").expect("read"),
|
||||||
.cursor(SCOPE_REPO, "gitea", "acme/barn")
|
|
||||||
.expect("read"),
|
|
||||||
Some("2026-10-08T00:00:00Z".to_owned())
|
Some("2026-10-08T00:00:00Z".to_owned())
|
||||||
);
|
);
|
||||||
// Another watch of the same forge is another cursor.
|
// Another watch of the same forge is another cursor.
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
store
|
store.cursor(SCOPE_REPO, "gitea", "acme/quarry").expect("read"),
|
||||||
.cursor(SCOPE_REPO, "gitea", "acme/quarry")
|
|
||||||
.expect("read"),
|
|
||||||
None
|
None
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -731,9 +725,7 @@ mod tests {
|
|||||||
.set_cursor(SCOPE_REPO, "gitea", "acme/barn", "2026-10-09T00:00:00Z")
|
.set_cursor(SCOPE_REPO, "gitea", "acme/barn", "2026-10-09T00:00:00Z")
|
||||||
.expect("the cursor advances");
|
.expect("the cursor advances");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
store
|
store.cursor(SCOPE_REPO, "gitea", "acme/barn").expect("read"),
|
||||||
.cursor(SCOPE_REPO, "gitea", "acme/barn")
|
|
||||||
.expect("read"),
|
|
||||||
Some("2026-10-09T00:00:00Z".to_owned())
|
Some("2026-10-09T00:00:00Z".to_owned())
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -744,9 +736,7 @@ mod tests {
|
|||||||
.expect("add");
|
.expect("add");
|
||||||
store.remove("gitea", "acme/barn").expect("remove");
|
store.remove("gitea", "acme/barn").expect("remove");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
store
|
store.cursor(SCOPE_REPO, "gitea", "acme/barn").expect("read"),
|
||||||
.cursor(SCOPE_REPO, "gitea", "acme/barn")
|
|
||||||
.expect("read"),
|
|
||||||
None
|
None
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ use rhema_claw::{ClawConfig, run_once};
|
|||||||
/// carrying watches, and the test speaks to the daemon the way an
|
/// carrying watches, and the test speaks to the daemon the way an
|
||||||
/// integration would: through the store the routes share.
|
/// integration would: through the store the routes share.
|
||||||
fn seed_watch(dir: &tempfile::TempDir, host: &str) {
|
fn seed_watch(dir: &tempfile::TempDir, host: &str) {
|
||||||
let store =
|
let store = rhema_claw::ClawStore::open(dir.path().join("dispatch.db"))
|
||||||
rhema_claw::ClawStore::open(dir.path().join("dispatch.db")).expect("the watch table opens");
|
.expect("the watch table opens");
|
||||||
store
|
store
|
||||||
.add("github", "acme/widgets", Some(host), "tok")
|
.add("github", "acme/widgets", Some(host), "tok")
|
||||||
.expect("the seed row lands");
|
.expect("the seed row lands");
|
||||||
@@ -22,12 +22,7 @@ fn seed_watch(dir: &tempfile::TempDir, host: &str) {
|
|||||||
// the feed from there instead of seeding one at *now* (which a
|
// the feed from there instead of seeding one at *now* (which a
|
||||||
// never-polled watch does, and which feeds nothing).
|
// never-polled watch does, and which feeds nothing).
|
||||||
store
|
store
|
||||||
.set_cursor(
|
.set_cursor(rhema_claw::SCOPE_REPO, "github", "acme/widgets", "2026-10-01T00:00:00Z")
|
||||||
rhema_claw::SCOPE_REPO,
|
|
||||||
"github",
|
|
||||||
"acme/widgets",
|
|
||||||
"2026-10-01T00:00:00Z",
|
|
||||||
)
|
|
||||||
.expect("the cursor seeds");
|
.expect("the cursor seeds");
|
||||||
}
|
}
|
||||||
use rhema_core::{Message, MockProvider, ModelOutput, Role, Session, StopReason, Usage};
|
use rhema_core::{Message, MockProvider, ModelOutput, Role, Session, StopReason, Usage};
|
||||||
|
|||||||
@@ -67,8 +67,8 @@ fn config(dir: &tempfile::TempDir) -> ClawConfig {
|
|||||||
/// carrying watches, and the test speaks to the daemon the way an
|
/// carrying watches, and the test speaks to the daemon the way an
|
||||||
/// integration would: through the store the routes share.
|
/// integration would: through the store the routes share.
|
||||||
fn seed_watch(dir: &tempfile::TempDir, host: &str) {
|
fn seed_watch(dir: &tempfile::TempDir, host: &str) {
|
||||||
let store =
|
let store = rhema_claw::ClawStore::open(dir.path().join("dispatch.db"))
|
||||||
rhema_claw::ClawStore::open(dir.path().join("dispatch.db")).expect("the watch table opens");
|
.expect("the watch table opens");
|
||||||
store
|
store
|
||||||
.add("github", "acme/widgets", Some(host), "tok")
|
.add("github", "acme/widgets", Some(host), "tok")
|
||||||
.expect("the seed row lands");
|
.expect("the seed row lands");
|
||||||
@@ -76,12 +76,7 @@ fn seed_watch(dir: &tempfile::TempDir, host: &str) {
|
|||||||
// the feed from there instead of seeding one at *now* (which a
|
// the feed from there instead of seeding one at *now* (which a
|
||||||
// never-polled watch does, and which feeds nothing).
|
// never-polled watch does, and which feeds nothing).
|
||||||
store
|
store
|
||||||
.set_cursor(
|
.set_cursor(rhema_claw::SCOPE_REPO, "github", "acme/widgets", "2026-10-01T00:00:00Z")
|
||||||
rhema_claw::SCOPE_REPO,
|
|
||||||
"github",
|
|
||||||
"acme/widgets",
|
|
||||||
"2026-10-01T00:00:00Z",
|
|
||||||
)
|
|
||||||
.expect("the cursor seeds");
|
.expect("the cursor seeds");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1119,12 +1119,7 @@ async fn watches_added_over_http_feed_the_next_detect_pass() {
|
|||||||
// Rewound to before the feed's rows — an established watch — the same
|
// Rewound to before the feed's rows — an established watch — the same
|
||||||
// pass detects the feed's event.
|
// pass detects the feed's event.
|
||||||
Arc::new(rhema_claw::ClawStore::open(dir.path().join("dispatch.db")).expect("reopens"))
|
Arc::new(rhema_claw::ClawStore::open(dir.path().join("dispatch.db")).expect("reopens"))
|
||||||
.set_cursor(
|
.set_cursor(rhema_claw::SCOPE_REPO, "github", "acme/widgets", "2026-10-01T00:00:00Z")
|
||||||
rhema_claw::SCOPE_REPO,
|
|
||||||
"github",
|
|
||||||
"acme/widgets",
|
|
||||||
"2026-10-01T00:00:00Z",
|
|
||||||
)
|
|
||||||
.expect("the cursor rewinds");
|
.expect("the cursor rewinds");
|
||||||
let report = daemon.tick().await.expect("the pass runs");
|
let report = daemon.tick().await.expect("the pass runs");
|
||||||
assert_eq!(report.detected, 1, "the new watch's feed event was fed");
|
assert_eq!(report.detected, 1, "the new watch's feed event was fed");
|
||||||
|
|||||||
@@ -397,9 +397,7 @@ impl Timestamp {
|
|||||||
let raw = if sub_millis == 0 {
|
let raw = if sub_millis == 0 {
|
||||||
format!("{year:04}-{month:02}-{day:02}T{hour:02}:{minute:02}:{second:02}Z")
|
format!("{year:04}-{month:02}-{day:02}T{hour:02}:{minute:02}:{second:02}Z")
|
||||||
} else {
|
} else {
|
||||||
format!(
|
format!("{year:04}-{month:02}-{day:02}T{hour:02}:{minute:02}:{second:02}.{sub_millis:03}Z")
|
||||||
"{year:04}-{month:02}-{day:02}T{hour:02}:{minute:02}:{second:02}.{sub_millis:03}Z"
|
|
||||||
)
|
|
||||||
};
|
};
|
||||||
Self::parse(&raw)
|
Self::parse(&raw)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -520,10 +520,7 @@ fn comment_urls(row: &WireComment) -> [Option<&str>; 3] {
|
|||||||
/// number is therefore read from the first URL that carries one, in
|
/// number is therefore read from the first URL that carries one, in
|
||||||
/// order of directness.
|
/// order of directness.
|
||||||
fn comment_parent(row: &WireComment) -> Option<u64> {
|
fn comment_parent(row: &WireComment) -> Option<u64> {
|
||||||
comment_urls(row)
|
comment_urls(row).into_iter().flatten().find_map(parent_number)
|
||||||
.into_iter()
|
|
||||||
.flatten()
|
|
||||||
.find_map(parent_number)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// [`comment_parent`]'s "is it a pull request" half: `pull_request_url`
|
/// [`comment_parent`]'s "is it a pull request" half: `pull_request_url`
|
||||||
|
|||||||
@@ -606,9 +606,6 @@ async fn poll_survives_a_comments_feed_with_blank_issue_urls() {
|
|||||||
.collect();
|
.collect();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
summary,
|
summary,
|
||||||
vec![
|
vec![(EventKind::Comment, 1, true), (EventKind::Comment, 2, false)]
|
||||||
(EventKind::Comment, 1, true),
|
|
||||||
(EventKind::Comment, 2, false)
|
|
||||||
]
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user