Skip to content

Commit 44c3bfa

Browse files
Split josh-graphql and josh-templates out of josh-core (#1339)
This reduces number of dependencies of josh-core
1 parent 301c8fd commit 44c3bfa

File tree

16 files changed

+118
-61
lines changed

16 files changed

+118
-61
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
!josh-proxy
99
!josh-rpc
1010
!josh-ssh-shell
11+
!josh-templates
12+
!josh-graphql
1113
!josh-ui/*.json
1214
!josh-ui/*.rs
1315
!josh-ui/*.toml

Cargo.lock

Lines changed: 35 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ members = [
44
"hyper_cgi",
55
"josh-core",
66
"josh-filter",
7+
"josh-graphql",
78
"josh-proxy",
89
"josh-rpc",
910
"josh-ssh-shell",
11+
"josh-templates",
1012
"josh-ui",
1113
]
1214

josh-core/Cargo.toml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ bitvec = "1.0.1"
1515
git-version = "0.3.9"
1616
git2 = { workspace = true }
1717
glob = "0.3.1"
18-
handlebars = "5.1.2"
1918
hex = "0.4.3"
2019
indoc = "2.0.5"
2120
itertools = "0.13.0"
@@ -31,13 +30,4 @@ serde = { workspace = true }
3130
serde_json = { workspace = true }
3231
serde_yaml = { workspace = true }
3332
sled = "0.34.7"
34-
strfmt = "0.2.4"
35-
toml = { workspace = true }
3633
tracing = { workspace = true }
37-
juniper = { workspace = true }
38-
form_urlencoded = "1.2.1"
39-
40-
[dependencies.chrono]
41-
default-features = false
42-
features = ["alloc", "std"]
43-
version = "0.4.38"

josh-core/src/filter/parse.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,6 @@ pub fn get_comments(filter_spec: &str) -> JoshResult<String> {
293293
)));
294294
}
295295

296-
#[derive(Parser)]
296+
#[derive(pest_derive::Parser)]
297297
#[grammar = "filter/grammar.pest"]
298298
struct Grammar;

josh-core/src/lib.rs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,10 @@ macro_rules! ok_or {
2525
#[macro_use]
2626
extern crate rs_tracing;
2727

28-
#[macro_use]
29-
extern crate handlebars;
30-
31-
#[macro_use]
32-
extern crate pest_derive;
33-
34-
#[macro_use]
35-
extern crate serde_json;
36-
3728
pub mod cache;
3829
pub mod filter;
39-
pub mod graphql;
4030
pub mod history;
4131
pub mod housekeeping;
42-
pub mod query;
4332
pub mod shell;
4433

4534
pub struct Change {
@@ -190,7 +179,7 @@ macro_rules! regex_parsed {
190179
impl $name {
191180
fn from_str(path: &str) -> Option<$name> {
192181

193-
lazy_static! {
182+
lazy_static::lazy_static! {
194183
static ref REGEX: regex::Regex =
195184
regex::Regex::new($re)
196185
.expect("can't compile regex");
@@ -368,7 +357,7 @@ type Users = std::collections::HashMap<String, User>;
368357

369358
#[derive(Debug, serde::Deserialize)]
370359
struct User {
371-
pub groups: toml::value::Array,
360+
pub groups: Vec<String>,
372361
}
373362

374363
type Groups = std::collections::HashMap<String, std::collections::HashMap<String, Group>>;
@@ -400,7 +389,7 @@ pub fn get_acl(
400389
let mut blacklist = filter::empty();
401390
for g in &u.groups {
402391
let lists = groups.get(repo).and_then(|repo| {
403-
repo.get(g.as_str()?).map(|group| {
392+
repo.get(g.as_str()).map(|group| {
404393
let w = filter::parse(&group.whitelist);
405394
let b = filter::parse(&group.blacklist);
406395
(w, b)

josh-filter/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ version = "22.4.15"
1111

1212
[dependencies]
1313
josh = { path = "../josh-core" }
14+
josh-graphql = { path = "../josh-graphql" }
15+
josh-templates = { path = "../josh-templates" }
1416
env_logger = { workspace = true }
1517
serde = { workspace = true }
1618
serde_json = { workspace = true }

josh-filter/src/bin/josh-filter.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -399,12 +399,12 @@ fn run_filter(args: Vec<String>) -> josh::JoshResult<i32> {
399399
}
400400

401401
if let Some(gql_query) = args.get_one::<String>("graphql") {
402-
let context = josh::graphql::context(transaction.try_clone()?, transaction.try_clone()?);
402+
let context = josh_graphql::context(transaction.try_clone()?, transaction.try_clone()?);
403403
*context.allow_refs.lock()? = true;
404404
let (res, _errors) = juniper::execute_sync(
405405
gql_query,
406406
None,
407-
&josh::graphql::repo_schema(".".to_string(), true),
407+
&josh_graphql::repo_schema(".".to_string(), true),
408408
&std::collections::HashMap::new(),
409409
&context,
410410
)?;
@@ -420,7 +420,7 @@ fn run_filter(args: Vec<String>) -> josh::JoshResult<i32> {
420420
let commit_id = transaction.repo().refname_to_id(update_target)?;
421421
print!(
422422
"{}",
423-
josh::query::render(&transaction, "", commit_id, query, false)?
423+
josh_templates::render(&transaction, "", commit_id, query, false)?
424424
.map(|x| x.0)
425425
.unwrap_or("File not found".to_string())
426426
);

josh-graphql/Cargo.toml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[package]
2+
name = "josh-graphql"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[dependencies]
7+
josh = { path = "../josh-core" }
8+
juniper = { workspace = true }
9+
git2 = { workspace = true }
10+
rs_tracing = { workspace = true }
11+
regex = { workspace = true }
12+
serde_json = { workspace = true }
13+
serde_yaml = { workspace = true }
14+
strfmt = "0.2.4"
15+
toml = { workspace = true }
16+
tracing = { workspace = true }
17+
lazy_static = { workspace = true }
18+
19+
[dependencies.chrono]
20+
default-features = false
21+
features = ["alloc", "std"]
22+
version = "0.4.38"

josh-core/src/graphql.rs renamed to josh-graphql/src/graphql.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![allow(unused_variables)]
22

3-
use super::*;
3+
use josh::{cache, filter, history, josh_error, JoshResult};
44
use juniper::{graphql_object, EmptyMutation, EmptySubscription, FieldResult};
55

66
pub struct Revision {
@@ -674,7 +674,7 @@ impl Path {
674674

675675
fn dir(&self, relative: String) -> FieldResult<Path> {
676676
Ok(Path {
677-
path: normalize_path(&self.path.join(relative)),
677+
path: josh::normalize_path(&self.path.join(relative)),
678678
commit_id: self.commit_id,
679679
filter: self.filter,
680680
tree: self.tree,
@@ -955,10 +955,7 @@ impl RepositoryMut {
955955
filter::nop()
956956
};
957957

958-
Ok(RevMut {
959-
at: at,
960-
filter: filter,
961-
})
958+
Ok(RevMut { at, filter })
962959
}
963960
}
964961

@@ -983,7 +980,7 @@ impl Repository {
983980
pattern.unwrap_or_else(|| "refs/heads/*".to_string())
984981
);
985982

986-
log::debug!("refname: {:?}", refname);
983+
tracing::debug!(refname = refname, "refs");
987984

988985
let mut refs = vec![];
989986

@@ -1029,7 +1026,7 @@ impl Repository {
10291026
}
10301027
}
10311028

1032-
regex_parsed!(
1029+
josh::regex_parsed!(
10331030
UpstreamRef,
10341031
r"refs/josh/upstream/.*[.]git/(?P<reference>refs/heads/.*)",
10351032
[reference]
@@ -1066,7 +1063,7 @@ pub fn repo_schema(name: String, local: bool) -> RepoSchema {
10661063
let ns = if local {
10671064
"".to_string()
10681065
} else {
1069-
format!("refs/josh/upstream/{}.git/", to_ns(&name))
1066+
format!("refs/josh/upstream/{}.git/", josh::to_ns(&name))
10701067
};
10711068
RepoSchema::new(
10721069
Repository { name, ns },

0 commit comments

Comments
 (0)