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
|
|
@ -1,12 +0,0 @@
|
|||
{
|
||||
"db_name": "SQLite",
|
||||
"query": "UPDATE commits SET new = false",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Right": 0
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "373c31648cfc15a3a42b51dc74025ee5fb1a90da7ecaf4bf4b330076f33e74dd"
|
||||
}
|
||||
12
.sqlx/query-3d48dcc84c3d624f7a9f9ebd0399aa9786cb94e2ddda6016fc0e8e0fee46fc98.json
generated
Normal file
12
.sqlx/query-3d48dcc84c3d624f7a9f9ebd0399aa9786cb94e2ddda6016fc0e8e0fee46fc98.json
generated
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"db_name": "SQLite",
|
||||
"query": "UPDATE commits SET new = false WHERE reachable = 2",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Right": 0
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "3d48dcc84c3d624f7a9f9ebd0399aa9786cb94e2ddda6016fc0e8e0fee46fc98"
|
||||
}
|
||||
|
|
@ -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(())
|
||||
|
|
|
|||
|
|
@ -227,7 +227,7 @@ async fn update_commit_tracked_status(conn: &mut SqliteConnection) -> somehow::R
|
|||
WHEN hash IN reachable THEN 1 \
|
||||
ELSE 0 \
|
||||
END \
|
||||
"
|
||||
"
|
||||
)
|
||||
.execute(conn)
|
||||
.await?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue