Skip to content

Commit

Permalink
adapt to changes in gix and gix-protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Dec 16, 2024
1 parent e59fc09 commit 5f11cc7
Show file tree
Hide file tree
Showing 19 changed files with 218 additions and 290 deletions.
405 changes: 145 additions & 260 deletions gitoxide-core/src/pack/receive.rs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion gitoxide-core/src/repository/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ pub(crate) mod function {

if handshake_info {
writeln!(out, "Handshake Information")?;
writeln!(out, "\t{:?}", fetch_outcome.ref_map.handshake)?;
writeln!(out, "\t{:?}", fetch_outcome.handshake)?;
}

match fetch_outcome.status {
Expand Down
2 changes: 1 addition & 1 deletion gitoxide-core/src/repository/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub(crate) mod function {

if handshake_info {
writeln!(out, "Handshake Information")?;
writeln!(out, "\t{:?}", res.ref_map.handshake)?;
writeln!(out, "\t{:?}", res.handshake)?;
}

let ref_specs = remote.refspecs(gix::remote::Direction::Fetch);
Expand Down
4 changes: 2 additions & 2 deletions gitoxide-core/src/repository/remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ mod refs_impl {
.context("Remote didn't have a URL to connect to")?
.to_bstring()
));
let map = remote
let (map, handshake) = remote
.connect(gix::remote::Direction::Fetch)
.await?
.ref_map(
Expand All @@ -86,7 +86,7 @@ mod refs_impl {

if handshake_info {
writeln!(out, "Handshake Information")?;
writeln!(out, "\t{:?}", map.handshake)?;
writeln!(out, "\t{handshake:?}")?;
}
match kind {
refs::Kind::Tracking { .. } => print_refmap(
Expand Down
1 change: 1 addition & 0 deletions gix/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ worktree-archive = ["gix-archive", "worktree-stream", "attributes"]
async-network-client = [
"gix-protocol/async-client",
"gix-pack/streaming-input",
"dep:gix-transport",
"attributes",
"credentials",
]
Expand Down
10 changes: 8 additions & 2 deletions gix/src/remote/connection/ref_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,14 @@ where
/// - `gitoxide.userAgent` is read to obtain the application user agent for git servers and for HTTP servers as well.
#[allow(clippy::result_large_err)]
#[gix_protocol::maybe_async::maybe_async]
pub async fn ref_map(mut self, progress: impl Progress, options: Options) -> Result<fetch::RefMap, Error> {
self.ref_map_by_ref(progress, options).await
pub async fn ref_map(
mut self,
progress: impl Progress,
options: Options,
) -> Result<(fetch::RefMap, gix_protocol::handshake::Outcome), Error> {
let refmap = self.ref_map_by_ref(progress, options).await;
let handshake = self.handshake.expect("refmap always performs handshake");
refmap.map(|map| (map, handshake))
}

#[allow(clippy::result_large_err)]
Expand Down
2 changes: 1 addition & 1 deletion gix/tests/gix/remote/ref_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ mod blocking_and_async_io {
daemon.as_ref(),
None,
);
let map = remote
let (map, _handshake) = remote
.connect(Fetch)
.await?
.ref_map(progress::Discard, Default::default())
Expand Down
1 change: 0 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ check:
if cargo check -p gix-transport --all-features 2>/dev/null; then false; else true; fi
if cargo check -p gix-protocol --all-features 2>/dev/null; then false; else true; fi
cargo tree -p gix --no-default-features -e normal -i imara-diff 2>&1 | grep warning # warning happens if nothing found, no exit code :/
if cargo tree -p gix --no-default-features -i gix-protocol 2>/dev/null; then false; else true; fi
cargo tree -p gix --no-default-features -e normal -i gix-submodule 2>&1 | grep warning
cargo tree -p gix --no-default-features -e normal -i gix-pathspec 2>&1 | grep warning
cargo tree -p gix --no-default-features -e normal -i gix-filter 2>&1 | grep warning
Expand Down
14 changes: 8 additions & 6 deletions tests/journey/gix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ title "gix (with repository)"
)
fi

(with "git:// protocol"
# for some reason, on CI the daemon always shuts down before we can connect,
# or isn't actually ready despite having accepted the first connection already.
(not_on_ci with "git:// protocol"
launch-git-daemon
(with "version 1"
it "generates the correct output" && {
Expand Down Expand Up @@ -249,14 +251,14 @@ title "gix commit-graph"
(with "version 2"
(with "NO output directory"
it "generates the correct output" && {
WITH_SNAPSHOT="$snapshot/file-v-any-no-output" \
WITH_SNAPSHOT="$snapshot/file-v-any-no-output-p2" \
expect_run $SUCCESSFULLY "$exe_plumbing" --no-verbose free pack receive -p 2 .git
}
)
(with "output directory"
mkdir out/
it "generates the correct output" && {
WITH_SNAPSHOT="$snapshot/file-v-any-with-output" \
WITH_SNAPSHOT="$snapshot/file-v-any-with-output-p2" \
expect_run $SUCCESSFULLY "$exe_plumbing" --no-verbose free pack receive .git out/
}
it "creates an index and a pack in the output directory" && {
Expand All @@ -268,7 +270,7 @@ title "gix commit-graph"
if test "$kind" = "max" || test "$kind" = "max-pure"; then
(with "--format json"
it "generates the correct output in JSON format" && {
WITH_SNAPSHOT="$snapshot/file-v-any-no-output-json" \
WITH_SNAPSHOT="$snapshot/file-v-any-no-output-json-p2" \
expect_run $SUCCESSFULLY "$exe_plumbing" --no-verbose --format json free pack receive --protocol 2 .git
}
)
Expand Down Expand Up @@ -305,7 +307,7 @@ title "gix commit-graph"
(with "NO output directory"
(with "NO wanted refs"
it "generates the correct output" && {
WITH_SNAPSHOT="$snapshot/file-v-any-no-output" \
WITH_SNAPSHOT="$snapshot/file-v-any-no-output-p2" \
expect_run $SUCCESSFULLY "$exe_plumbing" --no-verbose free pack receive -p 2 git://localhost/
}
)
Expand All @@ -324,7 +326,7 @@ title "gix commit-graph"
)
(with "output directory"
it "generates the correct output" && {
WITH_SNAPSHOT="$snapshot/file-v-any-with-output" \
WITH_SNAPSHOT="$snapshot/file-v-any-with-output-p2" \
expect_run $SUCCESSFULLY "$exe_plumbing" --no-verbose free pack receive git://localhost/ out/
}
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
index: c787de2aafb897417ca8167baeb146eabd18bc5f
pack: 346574b7331dc3a1724da218d622c6e1b6c66a57
index: 8e48437a86dfb3939de997bb66b4bbedde9c2259
pack: 24d2f055141373bf1011f1b0fce5dd8929a3a869

3f72b39ad1600e6dac63430c15e0d875e9d3f9d6 HEAD symref-target:refs/heads/main
ee3c97678e89db4eab7420b04aef51758359f152 refs/heads/dev
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"index": {
"index_version": "V2",
"index_hash": "c787de2aafb897417ca8167baeb146eabd18bc5f",
"data_hash": "346574b7331dc3a1724da218d622c6e1b6c66a57",
"index_hash": "8e48437a86dfb3939de997bb66b4bbedde9c2259",
"data_hash": "24d2f055141373bf1011f1b0fce5dd8929a3a869",
"num_objects": 9
},
"pack_kind": "V2",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"index": {
"index_version": "V2",
"index_hash": "8e48437a86dfb3939de997bb66b4bbedde9c2259",
"data_hash": "24d2f055141373bf1011f1b0fce5dd8929a3a869",
"num_objects": 9
},
"pack_kind": "V2",
"index_path": null,
"data_path": null,
"refs": [
{
"Direct": {
"path": "refs/heads/dev",
"object": "ee3c97678e89db4eab7420b04aef51758359f152"
}
},
{
"Direct": {
"path": "refs/heads/main",
"object": "3f72b39ad1600e6dac63430c15e0d875e9d3f9d6"
}
}
]
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Error: unknown ref refs/heads/does-not-exist
Error: None of the refspec(s) refs/heads/does-not-exist matched any of the 2 refs on the remote
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
index: 8e48437a86dfb3939de997bb66b4bbedde9c2259
pack: 24d2f055141373bf1011f1b0fce5dd8929a3a869

ee3c97678e89db4eab7420b04aef51758359f152 refs/heads/dev
3f72b39ad1600e6dac63430c15e0d875e9d3f9d6 refs/heads/main
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
index: 3ff97f80d63a1261147ace4cb06191a2fd686ff6
pack: de6c8d1e0ca3ee9331a3f92da74add15abd03049
index: c787de2aafb897417ca8167baeb146eabd18bc5f
pack: 346574b7331dc3a1724da218d622c6e1b6c66a57

ee3c97678e89db4eab7420b04aef51758359f152 refs/heads/dev
3f72b39ad1600e6dac63430c15e0d875e9d3f9d6 refs/heads/main
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
Error: Could not access repository or failed to read streaming pack file

Caused by:
Want to get specific refs, but remote doesn't support this capability
Error: None of the refspec(s) =refs/heads/main matched any of the 5 refs on the remote
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
index: c787de2aafb897417ca8167baeb146eabd18bc5f (out/pack-346574b7331dc3a1724da218d622c6e1b6c66a57.idx)
pack: 346574b7331dc3a1724da218d622c6e1b6c66a57 (out/pack-346574b7331dc3a1724da218d622c6e1b6c66a57.pack)
index: 8e48437a86dfb3939de997bb66b4bbedde9c2259 (out/pack-24d2f055141373bf1011f1b0fce5dd8929a3a869.idx)
pack: 24d2f055141373bf1011f1b0fce5dd8929a3a869 (out/pack-24d2f055141373bf1011f1b0fce5dd8929a3a869.pack)

3f72b39ad1600e6dac63430c15e0d875e9d3f9d6 HEAD symref-target:refs/heads/main
ee3c97678e89db4eab7420b04aef51758359f152 refs/heads/dev
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
index: 8e48437a86dfb3939de997bb66b4bbedde9c2259 (out/pack-24d2f055141373bf1011f1b0fce5dd8929a3a869.idx)
pack: 24d2f055141373bf1011f1b0fce5dd8929a3a869 (out/pack-24d2f055141373bf1011f1b0fce5dd8929a3a869.pack)

ee3c97678e89db4eab7420b04aef51758359f152 refs/heads/dev
3f72b39ad1600e6dac63430c15e0d875e9d3f9d6 refs/heads/main
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pack-346574b7331dc3a1724da218d622c6e1b6c66a57.idx
pack-346574b7331dc3a1724da218d622c6e1b6c66a57.keep
pack-346574b7331dc3a1724da218d622c6e1b6c66a57.pack
pack-24d2f055141373bf1011f1b0fce5dd8929a3a869.idx
pack-24d2f055141373bf1011f1b0fce5dd8929a3a869.keep
pack-24d2f055141373bf1011f1b0fce5dd8929a3a869.pack

0 comments on commit 5f11cc7

Please sign in to comment.