2 releases

0.1.1 Jun 7, 2022
0.1.0 Jun 7, 2022

#1349 in Development tools

Download history 183/week @ 2024-07-22 151/week @ 2024-07-29 166/week @ 2024-08-05 184/week @ 2024-08-12 174/week @ 2024-08-19 140/week @ 2024-08-26 192/week @ 2024-09-02 66/week @ 2024-09-09 160/week @ 2024-09-16 199/week @ 2024-09-23 145/week @ 2024-09-30 119/week @ 2024-10-07 200/week @ 2024-10-14 272/week @ 2024-10-21 116/week @ 2024-10-28 242/week @ 2024-11-04

831 downloads per month

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

~5–15MB
~206K SLoC