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::triage::{self, Triage};
|
||||
use rhema_forge_integration::{
|
||||
Forge, GitHubForge, GitLabForge, GiteaForge, Notification, RepoRef, Timestamp, Watcher,
|
||||
register_forge,
|
||||
Forge, GitHubForge, GitLabForge, GiteaForge, Notification, Timestamp, Watcher, register_forge,
|
||||
};
|
||||
use rhema_identity::{IdentityStore, SecretKind};
|
||||
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) {
|
||||
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()))?;
|
||||
self.store
|
||||
.set_cursor(SCOPE_REPO, &record.forge, &record.repo, now.raw())
|
||||
@@ -620,7 +619,13 @@ mod tests {
|
||||
.add("gitea", "acme/barn", Some(&server.uri()), "tok")
|
||||
.expect("add");
|
||||
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!(
|
||||
source.detect().await.expect("the pass runs"),
|
||||
@@ -662,9 +667,7 @@ mod tests {
|
||||
Some(cursor)
|
||||
);
|
||||
assert_eq!(
|
||||
store
|
||||
.health(SCOPE_REPO, "gitea", "acme/barn")
|
||||
.expect("health reads")
|
||||
store.health(SCOPE_REPO, "gitea", "acme/barn").expect("health reads")
|
||||
.map(|health| health.consecutive_failures),
|
||||
Some(0),
|
||||
"the watch polled cleanly"
|
||||
|
||||
@@ -703,9 +703,7 @@ mod tests {
|
||||
fn a_cursor_is_kept_per_watch_and_moves_forward() {
|
||||
let store = ClawStore::in_memory().expect("store opens");
|
||||
assert_eq!(
|
||||
store
|
||||
.cursor(SCOPE_REPO, "gitea", "acme/barn")
|
||||
.expect("read"),
|
||||
store.cursor(SCOPE_REPO, "gitea", "acme/barn").expect("read"),
|
||||
None,
|
||||
"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")
|
||||
.expect("cursor lands");
|
||||
assert_eq!(
|
||||
store
|
||||
.cursor(SCOPE_REPO, "gitea", "acme/barn")
|
||||
.expect("read"),
|
||||
store.cursor(SCOPE_REPO, "gitea", "acme/barn").expect("read"),
|
||||
Some("2026-10-08T00:00:00Z".to_owned())
|
||||
);
|
||||
// Another watch of the same forge is another cursor.
|
||||
assert_eq!(
|
||||
store
|
||||
.cursor(SCOPE_REPO, "gitea", "acme/quarry")
|
||||
.expect("read"),
|
||||
store.cursor(SCOPE_REPO, "gitea", "acme/quarry").expect("read"),
|
||||
None
|
||||
);
|
||||
|
||||
@@ -731,9 +725,7 @@ mod tests {
|
||||
.set_cursor(SCOPE_REPO, "gitea", "acme/barn", "2026-10-09T00:00:00Z")
|
||||
.expect("the cursor advances");
|
||||
assert_eq!(
|
||||
store
|
||||
.cursor(SCOPE_REPO, "gitea", "acme/barn")
|
||||
.expect("read"),
|
||||
store.cursor(SCOPE_REPO, "gitea", "acme/barn").expect("read"),
|
||||
Some("2026-10-09T00:00:00Z".to_owned())
|
||||
);
|
||||
|
||||
@@ -744,9 +736,7 @@ mod tests {
|
||||
.expect("add");
|
||||
store.remove("gitea", "acme/barn").expect("remove");
|
||||
assert_eq!(
|
||||
store
|
||||
.cursor(SCOPE_REPO, "gitea", "acme/barn")
|
||||
.expect("read"),
|
||||
store.cursor(SCOPE_REPO, "gitea", "acme/barn").expect("read"),
|
||||
None
|
||||
);
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@ use rhema_claw::{ClawConfig, run_once};
|
||||
/// carrying watches, and the test speaks to the daemon the way an
|
||||
/// integration would: through the store the routes share.
|
||||
fn seed_watch(dir: &tempfile::TempDir, host: &str) {
|
||||
let store =
|
||||
rhema_claw::ClawStore::open(dir.path().join("dispatch.db")).expect("the watch table opens");
|
||||
let store = rhema_claw::ClawStore::open(dir.path().join("dispatch.db"))
|
||||
.expect("the watch table opens");
|
||||
store
|
||||
.add("github", "acme/widgets", Some(host), "tok")
|
||||
.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
|
||||
// never-polled watch does, and which feeds nothing).
|
||||
store
|
||||
.set_cursor(
|
||||
rhema_claw::SCOPE_REPO,
|
||||
"github",
|
||||
"acme/widgets",
|
||||
"2026-10-01T00:00:00Z",
|
||||
)
|
||||
.set_cursor(rhema_claw::SCOPE_REPO, "github", "acme/widgets", "2026-10-01T00:00:00Z")
|
||||
.expect("the cursor seeds");
|
||||
}
|
||||
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
|
||||
/// integration would: through the store the routes share.
|
||||
fn seed_watch(dir: &tempfile::TempDir, host: &str) {
|
||||
let store =
|
||||
rhema_claw::ClawStore::open(dir.path().join("dispatch.db")).expect("the watch table opens");
|
||||
let store = rhema_claw::ClawStore::open(dir.path().join("dispatch.db"))
|
||||
.expect("the watch table opens");
|
||||
store
|
||||
.add("github", "acme/widgets", Some(host), "tok")
|
||||
.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
|
||||
// never-polled watch does, and which feeds nothing).
|
||||
store
|
||||
.set_cursor(
|
||||
rhema_claw::SCOPE_REPO,
|
||||
"github",
|
||||
"acme/widgets",
|
||||
"2026-10-01T00:00:00Z",
|
||||
)
|
||||
.set_cursor(rhema_claw::SCOPE_REPO, "github", "acme/widgets", "2026-10-01T00:00:00Z")
|
||||
.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
|
||||
// pass detects the feed's event.
|
||||
Arc::new(rhema_claw::ClawStore::open(dir.path().join("dispatch.db")).expect("reopens"))
|
||||
.set_cursor(
|
||||
rhema_claw::SCOPE_REPO,
|
||||
"github",
|
||||
"acme/widgets",
|
||||
"2026-10-01T00:00:00Z",
|
||||
)
|
||||
.set_cursor(rhema_claw::SCOPE_REPO, "github", "acme/widgets", "2026-10-01T00:00:00Z")
|
||||
.expect("the cursor rewinds");
|
||||
let report = daemon.tick().await.expect("the pass runs");
|
||||
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 {
|
||||
format!("{year:04}-{month:02}-{day:02}T{hour:02}:{minute:02}:{second:02}Z")
|
||||
} else {
|
||||
format!(
|
||||
"{year:04}-{month:02}-{day:02}T{hour:02}:{minute:02}:{second:02}.{sub_millis:03}Z"
|
||||
)
|
||||
format!("{year:04}-{month:02}-{day:02}T{hour:02}:{minute:02}:{second:02}.{sub_millis:03}Z")
|
||||
};
|
||||
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
|
||||
/// order of directness.
|
||||
fn comment_parent(row: &WireComment) -> Option<u64> {
|
||||
comment_urls(row)
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.find_map(parent_number)
|
||||
comment_urls(row).into_iter().flatten().find_map(parent_number)
|
||||
}
|
||||
|
||||
/// [`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();
|
||||
assert_eq!(
|
||||
summary,
|
||||
vec![
|
||||
(EventKind::Comment, 1, true),
|
||||
(EventKind::Comment, 2, false)
|
||||
]
|
||||
vec![(EventKind::Comment, 1, true), (EventKind::Comment, 2, false)]
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user