Skip to content

Commit 7ecb2b2

Browse files
committed
New DSN parser
1 parent beb87c3 commit 7ecb2b2

33 files changed

+5254
-2824
lines changed
+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
on:
2+
push:
3+
tags:
4+
- releases/gel-dsn/v*
5+
6+
name: Release gel-dsn
7+
8+
jobs:
9+
test_and_publish:
10+
name: Test and publish
11+
runs-on: ubuntu-latest
12+
permissions:
13+
id-token: "write"
14+
contents: "read"
15+
steps:
16+
- name: checkout and env setup
17+
uses: actions/checkout@v3
18+
19+
- name: Extract project name and version
20+
run: |
21+
set -x
22+
PROJECT_NAME=$(echo $GITHUB_REF | sed -E 's|refs/tags/releases/([^/]+)/v.*|\1|')
23+
VERSION=$(echo $GITHUB_REF | sed -E 's|.*/v(.*)|\1|')
24+
echo "PROJECT_NAME=$PROJECT_NAME" >> $GITHUB_ENV
25+
echo "VERSION=$VERSION" >> $GITHUB_ENV
26+
27+
# verify that git tag matches cargo version
28+
- run: |
29+
set -x
30+
cargo_version="$(cargo metadata --format-version 1 \
31+
| jq -r '.packages[] | select(.name=="${{ env.PROJECT_NAME }}") | .version')"
32+
test "$cargo_version" = "${{ env.VERSION }}"
33+
34+
- name: Install Rust
35+
uses: dtolnay/rust-toolchain@master
36+
with:
37+
toolchain: stable
38+
components: rustfmt, clippy
39+
40+
- working-directory: ./${{ env.PROJECT_NAME }}
41+
run: |
42+
cargo publish --token=${{ secrets.CARGO_REGISTRY_TOKEN }}

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "gel-dsn/tests/gel/shared-client-testcases"]
2+
path = gel-dsn/tests/gel/shared-client-testcases
3+
url = https://github.com/geldata/shared-client-testcases.git

gel-dsn/Cargo.toml

+13
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,16 @@ readme = "README.md"
99
rust-version.workspace = true
1010

1111
[features]
12+
default = []
1213
gel = ["serde", "dirs"]
1314
postgres = []
1415
serde = ["dep:serde", "gel-stream/serde"]
16+
log = ["dep:log"]
17+
# If true, automatically enables the log and warning listeners in the parsers
18+
auto-log-trace = ["log"]
19+
auto-log-warning = ["log"]
20+
# Some CLI-private features that may change
21+
unstable = []
1522

1623
[dependencies]
1724
percent-encoding = "2"
@@ -28,6 +35,7 @@ rustls-pemfile = "2"
2835
sha1 = "0.10"
2936
dirs = { version = "6.0.0", optional = true }
3037
whoami = "1.5"
38+
log = { optional = true, version = "0.4" }
3139

3240
gel-stream = { path = "../gel-stream", version = "0" }
3341
gel-auth = { path = "../gel-auth", version = "0" }
@@ -48,6 +56,11 @@ tempfile = "3"
4856
[lints.rust]
4957
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(use_libpq)'] }
5058

59+
[[test]]
60+
name = "gel"
61+
path = "tests/gel/test.rs"
62+
harness = false
63+
5164
[[test]]
5265
name = "postgres"
5366
path = "tests/postgres/test.rs"

gel-dsn/src/file.rs

+18
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ pub trait FileAccess {
3030
}
3131
}
3232

33+
fn exists_dir(&self, path: &Path) -> Result<bool, std::io::Error>;
34+
3335
fn canonicalize(&self, path: &Path) -> Result<PathBuf, std::io::Error> {
3436
Ok(path.to_path_buf())
3537
}
@@ -45,6 +47,10 @@ impl FileAccess for &[(&Path, &str)] {
4547
"File not found",
4648
))
4749
}
50+
51+
fn exists_dir(&self, path: &Path) -> Result<bool, std::io::Error> {
52+
Ok(self.iter().any(|(key, _)| key.starts_with(path)))
53+
}
4854
}
4955

5056
impl<K, V> FileAccess for HashMap<K, V>
@@ -60,6 +66,10 @@ where
6066
"File not found",
6167
))
6268
}
69+
70+
fn exists_dir(&self, path: &Path) -> Result<bool, std::io::Error> {
71+
Ok(self.iter().any(|(key, _)| key.borrow().starts_with(path)))
72+
}
6373
}
6474

6575
impl FileAccess for () {
@@ -69,6 +79,10 @@ impl FileAccess for () {
6979
"File not found",
7080
))
7181
}
82+
83+
fn exists_dir(&self, _: &Path) -> Result<bool, std::io::Error> {
84+
Ok(false)
85+
}
7286
}
7387

7488
impl FileAccess for SystemFileAccess {
@@ -88,6 +102,10 @@ impl FileAccess for SystemFileAccess {
88102
std::fs::exists(path)
89103
}
90104

105+
fn exists_dir(&self, path: &Path) -> Result<bool, std::io::Error> {
106+
std::fs::metadata(path).map(|metadata| metadata.is_dir())
107+
}
108+
91109
fn canonicalize(&self, path: &Path) -> Result<PathBuf, std::io::Error> {
92110
std::fs::canonicalize(path)
93111
}

0 commit comments

Comments
 (0)