Revert "refactor(ptth_relay): replace custom Git version embedding with `git-version` crate"

This reverts commit 57058e5c0f.
main
_ 2024-01-21 20:32:34 -06:00
parent 57058e5c0f
commit 5965a76c75
7 changed files with 39 additions and 59 deletions

72
Cargo.lock generated
View File

@ -65,7 +65,7 @@ checksum = "31e6e93155431f3931513b243d371981bb2770112b370c82745a1d19d2f99364"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.105",
"syn",
]
[[package]]
@ -315,7 +315,7 @@ dependencies = [
"proc-macro2",
"quote",
"scratch",
"syn 1.0.105",
"syn",
]
[[package]]
@ -332,7 +332,7 @@ checksum = "1362b0ddcfc4eb0a1f57b68bd77dd99f0e826958a96abd0ae9bd092e114ffed6"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.105",
"syn",
]
[[package]]
@ -526,7 +526,7 @@ checksum = "bdfb8ce053d86b91919aad980c220b1fb8401a9394410e1c289ed7e66b61835d"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.105",
"syn",
]
[[package]]
@ -589,26 +589,6 @@ dependencies = [
"wasi 0.11.0+wasi-snapshot-preview1",
]
[[package]]
name = "git-version"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ad568aa3db0fcbc81f2f116137f263d7304f512a1209b35b85150d3ef88ad19"
dependencies = [
"git-version-macro",
]
[[package]]
name = "git-version-macro"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53010ccb100b96a67bc32c0175f0ed1426b31b655d562898e57325f81c023ac0"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.48",
]
[[package]]
name = "h2"
version = "0.3.15"
@ -1030,7 +1010,7 @@ checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.105",
"syn",
]
[[package]]
@ -1132,7 +1112,7 @@ dependencies = [
"pest_meta",
"proc-macro2",
"quote",
"syn 1.0.105",
"syn",
]
[[package]]
@ -1163,7 +1143,7 @@ checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.105",
"syn",
]
[[package]]
@ -1199,7 +1179,7 @@ dependencies = [
"proc-macro-error-attr",
"proc-macro2",
"quote",
"syn 1.0.105",
"syn",
"version_check",
]
@ -1216,9 +1196,9 @@ dependencies = [
[[package]]
name = "proc-macro2"
version = "1.0.78"
version = "1.0.47"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae"
checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725"
dependencies = [
"unicode-ident",
]
@ -1364,7 +1344,6 @@ dependencies = [
"dashmap",
"futures",
"futures-util",
"git-version",
"handlebars",
"http",
"hyper",
@ -1519,9 +1498,9 @@ dependencies = [
[[package]]
name = "quote"
version = "1.0.35"
version = "1.0.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef"
checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179"
dependencies = [
"proc-macro2",
]
@ -1723,7 +1702,7 @@ dependencies = [
"proc-macro2",
"quote",
"rust-embed-utils",
"syn 1.0.105",
"syn",
"walkdir",
]
@ -1887,7 +1866,7 @@ checksum = "255abe9a125a985c05190d687b320c12f9b1f0b99445e608c21ba0782c719ad8"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.105",
"syn",
]
[[package]]
@ -2030,7 +2009,7 @@ dependencies = [
"proc-macro-error",
"proc-macro2",
"quote",
"syn 1.0.105",
"syn",
]
[[package]]
@ -2050,17 +2029,6 @@ dependencies = [
"unicode-ident",
]
[[package]]
name = "syn"
version = "2.0.48"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "tempfile"
version = "3.3.0"
@ -2110,7 +2078,7 @@ checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.105",
"syn",
]
[[package]]
@ -2192,7 +2160,7 @@ checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.105",
"syn",
]
[[package]]
@ -2276,7 +2244,7 @@ checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.105",
"syn",
]
[[package]]
@ -2536,7 +2504,7 @@ dependencies = [
"once_cell",
"proc-macro2",
"quote",
"syn 1.0.105",
"syn",
"wasm-bindgen-shared",
]
@ -2570,7 +2538,7 @@ checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.105",
"syn",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]

View File

@ -78,4 +78,7 @@ WORKDIR /home/ptth_user
COPY --from=build /ptth/target/release/ptth_relay ./
COPY --from=build /ptth/handlebars/relay ./handlebars/relay
ARG git_version
RUN echo -n "$git_version" > ./git_version.txt
CMD ["/usr/bin/tini", "--", "./ptth_relay"]

View File

@ -8,11 +8,12 @@ DOCKER_TAG="ptth:latest"
mkdir -p app_packages
git archive --format=tar "$GIT_COMMIT" | sudo docker build -t "$DOCKER_TAG" -
git archive --format=tar "$GIT_COMMIT" | sudo docker build -t "$DOCKER_TAG" --build-arg "git_version=$GIT_COMMIT" -
sudo docker run --rm "$DOCKER_TAG" tar -c \
ptth_relay \
handlebars \
git_version.txt \
| gzip > "app_packages/ptth_relay_$GIT_COMMIT_SHORT.tar.gz"
sudo docker build -f app_package_Dockerfile -t ptth_app_host:latest .

View File

@ -38,7 +38,6 @@ tracing-futures = "0.2.4"
tracing-subscriber = "0.2.15"
ptth_core = { path = "../ptth_core", version = "2.0.0" }
git-version = "0.3.9"
[dependencies.reqwest]
version = "0.11.13"

View File

@ -1,3 +1,3 @@
pub fn read () -> &'static str {
git_version::git_version!(args = ["--abbrev=16", "--always", "--dirty=-modified"])
pub async fn read () -> Option <String> {
tokio::fs::read_to_string ("git_version.txt").await.ok ()
}

View File

@ -264,7 +264,7 @@ struct ServerEntry <'a> {
#[derive (Serialize)]
struct ServerListPage <'a> {
dev_mode: bool,
git_version: &'static str,
git_version: Option <String>,
servers: Vec <ServerEntry <'a>>,
news_url: Option <String>,
connected_server_count: usize,
@ -308,7 +308,7 @@ async fn handle_server_list_internal (state: &Relay)
dev_mode = guard.iso.dev_mode.is_some ();
news_url = guard.news_url.clone ();
}
let git_version = git_version::read ();
let git_version = git_version::read ().await;
let server_list = scraper_api::v1_server_list (&state).await;
@ -780,7 +780,12 @@ pub async fn run_relay (
{
let handlebars = Arc::new (load_templates (asset_root)?);
info! ("ptth_relay Git version: {}", git_version::read ());
if let Some (x) = git_version::read ().await {
info! ("ptth_relay Git version: {:?}", x);
}
else {
info! ("ptth_relay not built from Git");
}
if let Some (config_reload_path) = config_reload_path {
let state_2 = state.clone ();

View File

@ -90,7 +90,11 @@ AIABAACAAQAAgAEAAIABAACAAQAAgAEAAIABAACAAQAA" rel="icon" type="image/x-icon" />
<a href="../audit_log">Audit log</a>
<div style="color: #888; padding-top: 1em;">
{{#if git_version}}
Git version: {{git_version}}
{{else}}
Not built from Git
{{/if}}
<p>
Rendered by PTTH relay server.