Skip to content

Commit eaec1bc

Browse files
feat: add gix-serve crate wiring together upload-pack serving
1 parent 1d92205 commit eaec1bc

File tree

16 files changed

+643
-0
lines changed

16 files changed

+643
-0
lines changed

Cargo.lock

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ members = [
268268
"gix-transport",
269269
"gix-credentials",
270270
"gix-protocol",
271+
"gix-serve",
271272
"gix-pack",
272273
"gix-odb",
273274
"gix-tempfile",

gix-serve/Cargo.toml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
lints.workspace = true
2+
3+
[package]
4+
name = "gix-serve"
5+
version = "0.1.0"
6+
repository = "https://github.com/GitoxideLabs/gitoxide"
7+
license = "MIT OR Apache-2.0"
8+
description = "A crate of the gitoxide project for serving git repositories"
9+
authors = ["Sebastian Thiel <sebastian.thiel@icloud.com>"]
10+
edition = "2021"
11+
include = ["src/**/*", "LICENSE-*"]
12+
rust-version = "1.82"
13+
14+
[lib]
15+
doctest = false
16+
17+
[features]
18+
## Enable support for SHA-1 hashes.
19+
sha1 = ["gix-hash/sha1"]
20+
## Blocking server support.
21+
blocking-server = [
22+
"gix-protocol/blocking-server",
23+
"gix-transport/blocking-server",
24+
]
25+
26+
[dependencies]
27+
gix-ref = { version = "^0.61.0", path = "../gix-ref" }
28+
gix-hash = { version = "^0.23.0", path = "../gix-hash" }
29+
gix-pack = { version = "^0.68.0", path = "../gix-pack", features = [
30+
"generate",
31+
] }
32+
gix-features = { version = "^0.46.2", path = "../gix-features" }
33+
gix-protocol = { version = "^0.59.0", path = "../gix-protocol", optional = true }
34+
gix-transport = { version = "^0.55.1", path = "../gix-transport", optional = true }
35+
bstr = { version = "1.12.0", default-features = false, features = ["std"] }
36+
thiserror = "2.0.18"
37+
38+
[dev-dependencies]
39+
gix-testtools = { path = "../tests/tools" }
40+
gix-odb = { version = "^0.78.0", path = "../gix-odb" }
41+
gix-packetline = { version = "^0.21.2", path = "../gix-packetline", features = [
42+
"blocking-io",
43+
] }
44+
gix-transport = { version = "^0.55.1", path = "../gix-transport", features = [
45+
"blocking-server",
46+
] }
47+
gix-serve = { path = ".", features = ["blocking-server"] }
48+
49+
[package.metadata.docs.rs]
50+
all-features = true

gix-serve/LICENSE-APACHE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../LICENSE-APACHE

gix-serve/LICENSE-MIT

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../LICENSE-MIT
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
set -eu -o pipefail
3+
4+
git init -q
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
set -eu -o pipefail
3+
4+
git init -q
5+
git checkout -q -b main
6+
git commit -q --allow-empty -m 'first commit'
7+
git branch feature
8+
git checkout -q -b dev
9+
git commit -q --allow-empty -m 'dev commit'
10+
git checkout -q main
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
set -eu -o pipefail
3+
4+
git init -q
5+
git checkout -q -b main
6+
git commit -q --allow-empty -m 'initial commit'
7+
git branch feature
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
set -eu -o pipefail
3+
4+
git init -q
5+
git checkout -q -b main
6+
git commit -q --allow-empty -m 'initial commit'
7+
git tag lightweight-tag
8+
git tag -a v1.0 -m 'version 1.0'
9+
git pack-refs --all

gix-serve/src/lib.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//! Server-side git protocol support for serving repositories.
2+
#![deny(missing_docs, rust_2018_idioms, unsafe_code)]
3+
4+
///
5+
pub mod pack;
6+
///
7+
pub mod refs;
8+
///
9+
#[cfg(feature = "blocking-server")]
10+
pub mod serve;
11+
12+
use bstr::BString;
13+
use gix_hash::ObjectId;
14+
15+
/// A reference ready for advertisement to clients.
16+
pub struct AdvertisableRef {
17+
/// The ref name, e.g. `refs/heads/main`.
18+
pub name: BString,
19+
/// The object ID the ref points to.
20+
pub object_id: ObjectId,
21+
/// The peeled object ID, if this is an annotated tag.
22+
pub peeled: Option<ObjectId>,
23+
/// The symref target, e.g. `refs/heads/main` for `HEAD`.
24+
pub symref_target: Option<BString>,
25+
}
26+
27+
/// Errors from collecting refs.
28+
#[derive(Debug, thiserror::Error)]
29+
#[allow(missing_docs)]
30+
pub enum Error {
31+
#[error(transparent)]
32+
Io(#[from] std::io::Error),
33+
#[error(transparent)]
34+
RefIter(#[from] gix_ref::packed::buffer::open::Error),
35+
#[error(transparent)]
36+
RefIterEntry(#[from] gix_ref::file::iter::loose_then_packed::Error),
37+
#[error(transparent)]
38+
RefFind(#[from] gix_ref::file::find::Error),
39+
}

0 commit comments

Comments
 (0)