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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO Write all refs to DB, not just tracked ones
|
||||||
async fn update_tracked_refs(
|
async fn update_tracked_refs(
|
||||||
conn: &mut SqliteConnection,
|
conn: &mut SqliteConnection,
|
||||||
repo: &Repository,
|
repo: &Repository,
|
||||||
|
|
@ -134,6 +135,7 @@ async fn update_tracked_refs(
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO tracked -> reachable, 0 = unreachable, 1 = reachable, 2 = reachable from tracked ref
|
||||||
async fn update_commit_tracked_status(conn: &mut SqliteConnection) -> somehow::Result<()> {
|
async fn update_commit_tracked_status(conn: &mut SqliteConnection) -> somehow::Result<()> {
|
||||||
sqlx::query!(
|
sqlx::query!(
|
||||||
"
|
"
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ use axum::{
|
||||||
extract::{Path, State},
|
extract::{Path, State},
|
||||||
response::IntoResponse,
|
response::IntoResponse,
|
||||||
};
|
};
|
||||||
use futures::TryStreamExt;
|
|
||||||
use gix::{prelude::ObjectIdExt, Id, ObjectId, ThreadSafeRepository};
|
use gix::{prelude::ObjectIdExt, Id, ObjectId, ThreadSafeRepository};
|
||||||
use sqlx::SqlitePool;
|
use sqlx::SqlitePool;
|
||||||
|
|
||||||
|
|
@ -14,14 +13,16 @@ use crate::{config::Config, repo, somehow};
|
||||||
struct Commit {
|
struct Commit {
|
||||||
hash: String,
|
hash: String,
|
||||||
description: String,
|
description: String,
|
||||||
|
tracked: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Commit {
|
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()?;
|
let commit = id.object()?.try_into_commit()?;
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
hash: id.to_string(),
|
hash: id.to_string(),
|
||||||
description: repo::format_commit_short(&commit)?,
|
description: repo::format_commit_short(&commit)?,
|
||||||
|
tracked,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -50,12 +51,18 @@ pub async fn get(
|
||||||
State(repo): State<Arc<ThreadSafeRepository>>,
|
State(repo): State<Arc<ThreadSafeRepository>>,
|
||||||
) -> somehow::Result<impl IntoResponse> {
|
) -> somehow::Result<impl IntoResponse> {
|
||||||
// Do this first because a &Repository can't be kept across awaits.
|
// 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)
|
let child_rows = sqlx::query!(
|
||||||
.fetch(&db)
|
"
|
||||||
.map_ok(|r| r.child)
|
SELECT child, tracked FROM commit_links
|
||||||
.try_collect::<Vec<_>>()
|
JOIN commits ON hash = child
|
||||||
|
WHERE parent = ?
|
||||||
|
",
|
||||||
|
hash
|
||||||
|
)
|
||||||
|
.fetch_all(&db)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
// TODO Include untracked info for current commit
|
||||||
let repo = repo.to_thread_local();
|
let repo = repo.to_thread_local();
|
||||||
let id = hash.parse::<ObjectId>()?.attach(&repo);
|
let id = hash.parse::<ObjectId>()?.attach(&repo);
|
||||||
let commit = id.object()?.try_into_commit()?;
|
let commit = id.object()?.try_into_commit()?;
|
||||||
|
|
@ -64,13 +71,14 @@ pub async fn get(
|
||||||
|
|
||||||
let mut parents = vec![];
|
let mut parents = vec![];
|
||||||
for id in commit.parent_ids() {
|
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![];
|
let mut children = vec![];
|
||||||
for hash in child_ids {
|
for row in child_rows {
|
||||||
let id = hash.parse::<ObjectId>()?.attach(&repo);
|
let id = row.child.parse::<ObjectId>()?.attach(&repo);
|
||||||
children.push(Commit::new(id)?);
|
children.push(Commit::new(id, row.tracked != 0)?);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(CommitIdTemplate {
|
Ok(CommitIdTemplate {
|
||||||
|
|
|
||||||
|
|
@ -82,3 +82,8 @@ dd {
|
||||||
grid: auto-flow / min-content max-content;
|
grid: auto-flow / min-content max-content;
|
||||||
column-gap: 1ch;
|
column-gap: 1ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.commit .untracked,
|
||||||
|
.commit .untracked a {
|
||||||
|
color: #777;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,13 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{% for commit in children %}
|
{% for commit in children %}
|
||||||
|
{% if commit.tracked %}
|
||||||
<dt>Child:</dt>
|
<dt>Child:</dt>
|
||||||
<dd><a href="{{ commit.hash }}">{{ commit.description }}</a></dd>
|
<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 %}
|
{% endfor %}
|
||||||
</dl>
|
</dl>
|
||||||
<pre class="message">{{ message }}</pre>
|
<pre class="message">{{ message }}</pre>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue