Fix new commits not being added to the queue
This commit is contained in:
parent
4bdca4d3c8
commit
3c4bbe3b6b
4 changed files with 29 additions and 16 deletions
|
|
@ -12,6 +12,7 @@ async fn inner(db: &SqlitePool) -> somehow::Result<()> {
|
|||
let new = sqlx::query!("SELECT hash FROM commits WHERE new AND reachable = 2")
|
||||
.fetch_all(&mut *conn)
|
||||
.await?;
|
||||
debug!("Found {} new commits", new.len());
|
||||
|
||||
// Insert them into the queue
|
||||
for row in new {
|
||||
|
|
@ -29,10 +30,22 @@ async fn inner(db: &SqlitePool) -> somehow::Result<()> {
|
|||
}
|
||||
}
|
||||
|
||||
// Mark all commits as old
|
||||
sqlx::query!("UPDATE commits SET new = false")
|
||||
// Mark all commits we just added to the queue as old. Commits from
|
||||
// untracked branches are not marked as old because otherwise we'd miss them
|
||||
// when they eventually end up in the tracked branches. This can for example
|
||||
// happen when a tracked branch is fast-forwarded to a commit from an
|
||||
// untracked branch.
|
||||
//
|
||||
// When tracked refs are updated, all new commits are automatically added to
|
||||
// the queue, since they were still new and have now transitioned to
|
||||
// reachable = 2. This should hopefully not be too big of a problem since
|
||||
// usually the main branch is also tracked. I think I'd rather implement
|
||||
// better queue management tools and graph UI than change this behaviour.
|
||||
let amount = sqlx::query!("UPDATE commits SET new = false WHERE reachable = 2")
|
||||
.execute(&mut *conn)
|
||||
.await?;
|
||||
.await?
|
||||
.rows_affected();
|
||||
debug!("Marked {amount} commits as old");
|
||||
|
||||
tx.commit().await?;
|
||||
Ok(())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue