2 releases

0.1.1 Jun 7, 2022
0.1.0 Jun 7, 2022

#1170 in Development tools

Download history 1/week @ 2024-01-29 45/week @ 2024-02-05 88/week @ 2024-02-12 26/week @ 2024-02-19 55/week @ 2024-02-26 23/week @ 2024-03-04 52/week @ 2024-03-11 45/week @ 2024-03-18 26/week @ 2024-03-25 120/week @ 2024-04-01 67/week @ 2024-04-08 115/week @ 2024-04-15

330 downloads per month
Used in viewy

MIT license

5KB
77 lines

git-download

Crates.io documentation CI

Microservices architecture requires sharing service definition files like in protocol buffer, for clients to access the server.

To share the files, one can choose primitive copy & paste approach but this is too vulnerable to human mistakes.

The second and now widely accepted approach is protodep however, this isn't the best solution for Rust programmers

Because we, Rust programmers, want to download the files just like this in build.rs.

// build.rs

git_download::repo("https://github.com/akiradeveloper/lol")
    .branch_name("v0.9.1")
    .add_file("lol-core/proto/lol-core.proto", "proto/lol.proto")
    .exec()?;

tonic_build::configure()
    .build_server(false)
    .compile(&["lol.proto"], &["proto"])?;

Usage

[build-dependencies]
git-download = "0.1"

Implementation

Internally, git-download uses sparse-checkout to download designated files not the entire repository.

The downloaded files are firstly put in temporary directory which is created by tempfile crate. In Linux, the directory is created in tmpfs which is an in-memory filesystem. Therefore, no disk write occurs before copying the file in the tmpfs to the destination path. We can avoid writing the unchanged content by comparing the content before copying.

Dependencies

~6–17MB
~218K SLoC