Skip to content

Commit 5e00485

Browse files
Merge pull request #135 from theseus-rs/fix-github-archive-bundles
fix: allow archives to be bundled from alternate github repositories
2 parents b186f73 + dc724b3 commit 5e00485

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ In either case, PostgreSQL will run in a separate process space.
3030
- ability to configure PostgreSQL startup options
3131
- URL based configuration
3232
- choice of native-tls vs rustls
33+
- support for installing PostgreSQL extensions
3334

3435
## Getting Started
3536

postgresql_archive/tests/zonky.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ async fn test_get_archive_and_extract() -> anyhow::Result<()> {
4545
#[cfg(all(target_os = "linux", target_arch = "x86_64"))]
4646
assert_eq!(1_023, files.len());
4747
#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
48-
assert_eq!(1_019, files.len());
48+
assert_eq!(1_021, files.len());
4949
#[cfg(all(target_os = "macos", target_arch = "x86_64"))]
50-
assert_eq!(1_019, files.len());
50+
assert_eq!(1_021, files.len());
5151
#[cfg(all(target_os = "windows", target_arch = "x86_64"))]
52-
assert_eq!(1_019, files.len());
52+
assert_eq!(1_021, files.len());
5353
remove_dir_all(&out_dir)?;
5454
Ok(())
5555
}

postgresql_embedded/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ anyhow = { workspace = true }
1515
postgresql_archive = { path = "../postgresql_archive", version = "0.16.3", default-features = false }
1616
target-triple = { workspace = true }
1717
tokio = { workspace = true, features = ["full"] }
18+
url = { workspace = true }
1819

1920
[dependencies]
2021
anyhow = { workspace = true }

postgresql_embedded/build/bundle.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
#![allow(dead_code)]
22

33
use anyhow::Result;
4-
use postgresql_archive::get_archive;
4+
use postgresql_archive::repository::github::repository::GitHub;
55
use postgresql_archive::VersionReq;
6+
use postgresql_archive::{get_archive, repository};
67
use std::fs::File;
78
use std::io::Write;
89
use std::path::PathBuf;
910
use std::str::FromStr;
1011
use std::{env, fs};
12+
use url::Url;
1113

1214
/// Stage the PostgreSQL archive when the `bundled` feature is enabled so that
1315
/// it can be included in the final binary. This is useful for creating a
@@ -38,6 +40,7 @@ pub(crate) async fn stage_postgresql_archive() -> Result<()> {
3840
return Ok(());
3941
}
4042

43+
register_github_repository()?;
4144
let (asset_version, archive) = get_archive(&releases_url, &version_req).await?;
4245

4346
fs::write(archive_version_file.clone(), asset_version.to_string())?;
@@ -48,3 +51,15 @@ pub(crate) async fn stage_postgresql_archive() -> Result<()> {
4851

4952
Ok(())
5053
}
54+
55+
fn register_github_repository() -> Result<()> {
56+
repository::registry::register(
57+
|url| {
58+
let parsed_url = Url::parse(url)?;
59+
let host = parsed_url.host_str().unwrap_or_default();
60+
Ok(host.ends_with("github.com"))
61+
},
62+
Box::new(GitHub::new),
63+
)?;
64+
Ok(())
65+
}

0 commit comments

Comments
 (0)