From 5871b19f8eb157b4ebe2613a7c1a3546d24d6f9b Mon Sep 17 00:00:00 2001 From: Joscha Date: Sat, 5 Aug 2023 01:55:40 +0200 Subject: [PATCH] Fix repo update choking on duplicated parents --- ...53428f264190c2c1614d8df8dd831fd668c121786e88.json | 12 ++++++++++++ ...18d815bc343b1e65e9aa00751f1a530dfc696a94c6dd.json | 12 ------------ src/update.rs | 4 +++- 3 files changed, 15 insertions(+), 13 deletions(-) create mode 100644 .sqlx/query-2af3e5b2458b2674034853428f264190c2c1614d8df8dd831fd668c121786e88.json delete mode 100644 .sqlx/query-99a988f87d9e1d9ca6b818d815bc343b1e65e9aa00751f1a530dfc696a94c6dd.json diff --git a/.sqlx/query-2af3e5b2458b2674034853428f264190c2c1614d8df8dd831fd668c121786e88.json b/.sqlx/query-2af3e5b2458b2674034853428f264190c2c1614d8df8dd831fd668c121786e88.json new file mode 100644 index 0000000..da9f54d --- /dev/null +++ b/.sqlx/query-2af3e5b2458b2674034853428f264190c2c1614d8df8dd831fd668c121786e88.json @@ -0,0 +1,12 @@ +{ + "db_name": "SQLite", + "query": "INSERT OR IGNORE INTO commit_links (parent, child) VALUES (?, ?)", + "describe": { + "columns": [], + "parameters": { + "Right": 2 + }, + "nullable": [] + }, + "hash": "2af3e5b2458b2674034853428f264190c2c1614d8df8dd831fd668c121786e88" +} diff --git a/.sqlx/query-99a988f87d9e1d9ca6b818d815bc343b1e65e9aa00751f1a530dfc696a94c6dd.json b/.sqlx/query-99a988f87d9e1d9ca6b818d815bc343b1e65e9aa00751f1a530dfc696a94c6dd.json deleted file mode 100644 index 2a3c25b..0000000 --- a/.sqlx/query-99a988f87d9e1d9ca6b818d815bc343b1e65e9aa00751f1a530dfc696a94c6dd.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "db_name": "SQLite", - "query": "INSERT INTO commit_links (parent, child) VALUES (?, ?)", - "describe": { - "columns": [], - "parameters": { - "Right": 2 - }, - "nullable": [] - }, - "hash": "99a988f87d9e1d9ca6b818d815bc343b1e65e9aa00751f1a530dfc696a94c6dd" -} diff --git a/src/update.rs b/src/update.rs index 7f80853..272fc36 100644 --- a/src/update.rs +++ b/src/update.rs @@ -97,8 +97,10 @@ async fn insert_new_commit_links(conn: &mut SqliteConnection, new: &[Info]) -> a let child = commit.id.to_string(); for parent in &commit.parent_ids { let parent = parent.to_string(); + // Commits *cough*linuxkernel*cough* may list the same parent + // multiple times, so we just ignore duplicates during insert. sqlx::query!( - "INSERT INTO commit_links (parent, child) VALUES (?, ?)", + "INSERT OR IGNORE INTO commit_links (parent, child) VALUES (?, ?)", parent, child )