diff --git a/Cargo.lock b/Cargo.lock
@@ -154,7 +154,7 @@ dependencies = [
"rustversion",
"serde",
"serde_urlencoded",
- "sync_wrapper 1.0.1",
+ "sync_wrapper",
"tokio",
"tower",
"tower-layer",
@@ -176,7 +176,7 @@ dependencies = [
"mime",
"pin-project-lite",
"rustversion",
- "sync_wrapper 1.0.1",
+ "sync_wrapper",
"tower-layer",
"tower-service",
]
@@ -2890,12 +2890,6 @@ dependencies = [
"unicode-ident",
]
-[[package]]
-name = "sync_wrapper"
-version = "0.1.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160"
-
[[package]]
name = "sync_wrapper"
version = "1.0.1"
@@ -3128,14 +3122,14 @@ dependencies = [
[[package]]
name = "tower"
-version = "0.5.1"
+version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2873938d487c3cfb9aed7546dc9f2711d867c9f90c46b889989a2cb84eba6b4f"
+checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9"
dependencies = [
"futures-core",
"futures-util",
"pin-project-lite",
- "sync_wrapper 0.1.2",
+ "sync_wrapper",
"tokio",
"tower-layer",
"tower-service",
diff --git a/src/database/indexer.rs b/src/database/indexer.rs
@@ -93,6 +93,7 @@ fn update_repository_metadata(scan_path: &Path, db: &rocksdb::DB) {
(r.unix_timestamp(), r.offset().whole_seconds())
},
default_branch: find_default_branch(&git_repository).ok().flatten(),
+ exported: repository_path.join("git-daemon-export-ok").exists(),
}
.insert(db, relative);
diff --git a/src/database/schema/mod.rs b/src/database/schema/mod.rs
@@ -9,4 +9,4 @@ pub mod tag;
pub type Yoked<T> = Yoke<T, Box<[u8]>>;
-pub const SCHEMA_VERSION: &str = "2";
+pub const SCHEMA_VERSION: &str = "3";
diff --git a/src/database/schema/repository.rs b/src/database/schema/repository.rs
@@ -28,6 +28,10 @@ pub struct Repository {
pub last_modified: (i64, i32),
/// The default branch for Git operations
pub default_branch: Option<String>,
+ /// Whether the repository is available for HTTP(s) cloning
+ ///
+ /// This is set to `true` based on the presence of `git-daemon-export-ok` in the repository
+ pub exported: bool,
}
pub type YokedRepository = Yoked<&'static <Repository as Archive>::Archived>;
diff --git a/src/methods/repo/summary.rs b/src/methods/repo/summary.rs
@@ -2,7 +2,7 @@ use std::{collections::BTreeMap, sync::Arc};
use anyhow::Context;
use askama::Template;
-use axum::{response::IntoResponse, Extension};
+use axum::{extract::Host, response::IntoResponse, Extension};
use rkyv::string::ArchivedString;
use crate::{
@@ -21,11 +21,14 @@ pub struct View {
refs: Refs,
commit_list: Vec<YokedCommit>,
branch: Option<Arc<str>>,
+ exported: bool,
+ host: String,
}
pub async fn handle(
Extension(repo): Extension<Repository>,
Extension(db): Extension<Arc<rocksdb::DB>>,
+ Host(host): Host,
) -> Result<impl IntoResponse> {
tokio::task::spawn_blocking(move || {
let repository = crate::database::schema::repository::Repository::open(&db, &*repo)?
@@ -57,6 +60,8 @@ pub async fn handle(
refs: Refs { heads, tags },
commit_list: commits,
branch: None,
+ exported: repository.get().exported,
+ host,
}))
})
.await
diff --git a/templates/repo/summary.html b/templates/repo/summary.html
@@ -61,6 +61,30 @@
</tr>
</tbody>
{%- endif %}
+
+ {% if exported %}
+ <tbody>
+ <tr class="separator">
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ </tr>
+ <tr class="no-background">
+ <th>Clone</th>
+ <th></th>
+ <th></th>
+ <th></th>
+ </tr>
+ <tr>
+ <td colspan="4">
+ <a rel="vcs-git" href="/{{ repo.display() }}" title="{{ repo.display() }} Git repository">
+ https://{{ host }}/{{ repo.display() }}
+ </a>
+ </td>
+ </tr>
+ </tbody>
+ {%- endif %}
</table>
</div>
{% endblock %}