Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace git2 with gix #129

Merged
merged 23 commits into from
Jul 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
f234c9b
fix doc-tests for 'changes' feature and run that on CI as well
Byron Jul 22, 2023
3fe885c
Add `gix` as alternative
Byron Jul 18, 2023
9cac8a8
Add more local git tests to run quickly (i.e. those that don't clone)
Byron Jul 18, 2023
141285e
Use `gix` for `crates_parallel()`
Byron Jul 18, 2023
fbf169c
convert `crates()` to `gix`
Byron Jul 18, 2023
cd7f910
use `gix` for `index_config()`
Byron Jul 18, 2023
2cf53dd
Use `gix` for implementing `crate_()`
Byron Jul 18, 2023
92291cf
Clone the crate index with `gix`
Byron Jul 18, 2023
ebfda0f
Use `gix` for `update()`
Byron Jul 18, 2023
8939074
thanks clippy
Byron Jul 18, 2023
940ed59
switch to latest `gix` version to smoothen API usage
Byron Jul 19, 2023
ab0f126
cargo-fmt on all portions that changed
Byron Jul 19, 2023
50edb46
fix alrogithm for finding the head-reference
Byron Jul 20, 2023
11a7522
additional protection against raciness when cloning in parallel
Byron Jul 20, 2023
beddca6
convert `Changes` from `git2` to `gix`
Byron Jul 22, 2023
d649f95
remove all remainders of `git2`
Byron Jul 22, 2023
90da01e
Re-use test utilities for a unified experience
Byron Jul 22, 2023
084f226
run `cargo fmt` on everything that changed in `changes.rs`
Byron Jul 22, 2023
f50308f
Use the latest `gix` release for API improvements
Byron Jul 22, 2023
7d70f8f
Add an example that gets the latest changed crate right after updatin…
Byron Jul 23, 2023
cc6b8f9
fix refspecs for updating the crates index
Byron Jul 23, 2023
5649466
improve "find_repo_head()" to be more resilient
Byron Jul 23, 2023
fed6904
use `thiserror` for the error type.
Byron Jul 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/cargo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- uses: actions-rs/cargo@v1
with:
command: test
args: --features=sparse-http,ssh
args: --features=sparse-http,ssh,changes,git-index-performance --release
- uses: actions-rs/cargo@v1
with:
command: check
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ _test

# May be created during tests, but should not be present
tests/testdata/sparse_registry_cache/cargo_home/registry/index/index.crates.io-6f17d22bba15001f/.cache/cr/at/crates-index
/tests/testdata/git-registry/
19 changes: 13 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ required-features = ["sparse-http"]
name = "sparse_http_ureq"
required-features = ["sparse-http"]

[[example]]
name = "update_and_get_latest"
required-features = ["changes"]

[dependencies]
git2 = { version = "0.17", default-features = false, optional = true }
gix = { version = "0.50.0", default-features = false, features = ["max-performance-safe", "blocking-network-client"], optional = true }
hex = { version = "0.4.3", features = ["serde"] }
home = "0.5.4"
http = { version = "0.2", optional = true }
Expand All @@ -33,11 +37,14 @@ serde = { version = "1.0.160", features = ["rc"] }
serde_derive = "1.0.160"
serde_json = "1.0.96"
smol_str = { version = "0.2.0", features = ["serde"] }
thiserror = "1.0.43"
toml = "0.7.3"

[dev-dependencies]
bytesize = "1.2.0"
cap = { version = "0.1.2", features = ["stats"] }
is_ci = "1.1.1"
tempfile = "3.5.0"
cap = "0.1.2"
ureq = { version = "2.7.1", features = ["http-interop"] }
reqwest = { version = "0.11.18", features = ["blocking", "gzip"] }

Expand All @@ -48,11 +55,11 @@ features = ["sparse-http"]
[features]
default = ["git-index", "https", "parallel"]
changes = ["git-index"]
git-index = ["dep:git2"]
https = ["git-index", "git2?/https"]
git-index = ["dep:gix"]
git-index-performance = ["git-index", "gix?/max-performance"]
https = ["git-index", "gix?/blocking-http-transport-curl"]
parallel = ["dep:rayon"]
vendored-openssl = ["git-index", "git2?/vendored-openssl"]
ssh = ["git-index", "git2?/ssh"]
ssh = ["git-index"] # at this time, `gix` does not need feature toggles for this as the `ssh` program is used. Native support is planned to match `git2`.
sparse-http = ["dep:http"]

[badges]
Expand Down
14 changes: 14 additions & 0 deletions examples/update_and_get_latest.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//! Updates the local git registry and extracts the latest most recent changes.
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut index = crates_index::Index::new_cargo_default()?;
println!("Updating index…");
index.update()?;

let limit = 10;
println!("The most recent {limit} changes:\n");
for change in index.changes()?.take(limit) {
let change = change?;
println!("{name} changed in {commit}", name = change.crate_name(), commit = change.commit_hex());
}
Ok(())
}
Loading
Loading