Grey out untracked children
This commit is contained in:
parent
b83d908d4b
commit
d031eee14e
6 changed files with 57 additions and 31 deletions
26
.sqlx/query-2846970f979d84f4ba4ba2cd659fc37347ea280ebdf584bc535f135f63610a66.json
generated
Normal file
26
.sqlx/query-2846970f979d84f4ba4ba2cd659fc37347ea280ebdf584bc535f135f63610a66.json
generated
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
"db_name": "SQLite",
|
||||
"query": "\nSELECT child, tracked FROM commit_links\nJOIN commits ON hash = child\nWHERE parent = ?\n ",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"name": "child",
|
||||
"ordinal": 0,
|
||||
"type_info": "Text"
|
||||
},
|
||||
{
|
||||
"name": "tracked",
|
||||
"ordinal": 1,
|
||||
"type_info": "Int64"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Right": 1
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "2846970f979d84f4ba4ba2cd659fc37347ea280ebdf584bc535f135f63610a66"
|
||||
}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
{
|
||||
"db_name": "SQLite",
|
||||
"query": "SELECT child FROM commit_links WHERE parent = ?",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"name": "child",
|
||||
"ordinal": 0,
|
||||
"type_info": "Text"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Right": 1
|
||||
},
|
||||
"nullable": [
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "c8172df79e5000f77a957a648fc12898959bfba8d12f31428b6e582ce2106719"
|
||||
}
|
||||
|
|
@ -103,6 +103,7 @@ async fn track_main_branch(conn: &mut SqliteConnection, repo: &Repository) -> so
|
|||
Ok(())
|
||||
}
|
||||
|
||||
// TODO Write all refs to DB, not just tracked ones
|
||||
async fn update_tracked_refs(
|
||||
conn: &mut SqliteConnection,
|
||||
repo: &Repository,
|
||||
|
|
@ -134,6 +135,7 @@ async fn update_tracked_refs(
|
|||
Ok(())
|
||||
}
|
||||
|
||||
// TODO tracked -> reachable, 0 = unreachable, 1 = reachable, 2 = reachable from tracked ref
|
||||
async fn update_commit_tracked_status(conn: &mut SqliteConnection) -> somehow::Result<()> {
|
||||
sqlx::query!(
|
||||
"
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ use axum::{
|
|||
extract::{Path, State},
|
||||
response::IntoResponse,
|
||||
};
|
||||
use futures::TryStreamExt;
|
||||
use gix::{prelude::ObjectIdExt, Id, ObjectId, ThreadSafeRepository};
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
|
|
@ -14,14 +13,16 @@ use crate::{config::Config, repo, somehow};
|
|||
struct Commit {
|
||||
hash: String,
|
||||
description: String,
|
||||
tracked: bool,
|
||||
}
|
||||
|
||||
impl Commit {
|
||||
fn new(id: Id<'_>) -> somehow::Result<Self> {
|
||||
fn new(id: Id<'_>, tracked: bool) -> somehow::Result<Self> {
|
||||
let commit = id.object()?.try_into_commit()?;
|
||||
Ok(Self {
|
||||
hash: id.to_string(),
|
||||
description: repo::format_commit_short(&commit)?,
|
||||
tracked,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -50,12 +51,18 @@ pub async fn get(
|
|||
State(repo): State<Arc<ThreadSafeRepository>>,
|
||||
) -> somehow::Result<impl IntoResponse> {
|
||||
// Do this first because a &Repository can't be kept across awaits.
|
||||
let child_ids = sqlx::query!("SELECT child FROM commit_links WHERE parent = ?", hash)
|
||||
.fetch(&db)
|
||||
.map_ok(|r| r.child)
|
||||
.try_collect::<Vec<_>>()
|
||||
let child_rows = sqlx::query!(
|
||||
"
|
||||
SELECT child, tracked FROM commit_links
|
||||
JOIN commits ON hash = child
|
||||
WHERE parent = ?
|
||||
",
|
||||
hash
|
||||
)
|
||||
.fetch_all(&db)
|
||||
.await?;
|
||||
|
||||
// TODO Include untracked info for current commit
|
||||
let repo = repo.to_thread_local();
|
||||
let id = hash.parse::<ObjectId>()?.attach(&repo);
|
||||
let commit = id.object()?.try_into_commit()?;
|
||||
|
|
@ -64,13 +71,14 @@ pub async fn get(
|
|||
|
||||
let mut parents = vec![];
|
||||
for id in commit.parent_ids() {
|
||||
parents.push(Commit::new(id)?);
|
||||
// TODO Include untracked info for parents
|
||||
parents.push(Commit::new(id, true)?);
|
||||
}
|
||||
|
||||
let mut children = vec![];
|
||||
for hash in child_ids {
|
||||
let id = hash.parse::<ObjectId>()?.attach(&repo);
|
||||
children.push(Commit::new(id)?);
|
||||
for row in child_rows {
|
||||
let id = row.child.parse::<ObjectId>()?.attach(&repo);
|
||||
children.push(Commit::new(id, row.tracked != 0)?);
|
||||
}
|
||||
|
||||
Ok(CommitIdTemplate {
|
||||
|
|
|
|||
|
|
@ -82,3 +82,8 @@ dd {
|
|||
grid: auto-flow / min-content max-content;
|
||||
column-gap: 1ch;
|
||||
}
|
||||
|
||||
.commit .untracked,
|
||||
.commit .untracked a {
|
||||
color: #777;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,8 +25,13 @@
|
|||
{% endfor %}
|
||||
|
||||
{% for commit in children %}
|
||||
{% if commit.tracked %}
|
||||
<dt>Child:</dt>
|
||||
<dd><a href="{{ commit.hash }}">{{ commit.description }}</a></dd>
|
||||
{% else %}
|
||||
<dt class="untracked">Child:</dt>
|
||||
<dd class="untracked"><a href="{{ commit.hash }}">{{ commit.description }}</a></dd>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</dl>
|
||||
<pre class="message">{{ message }}</pre>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue