Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ members = [
]

[workspace.package]
version = "2.1.5"
version = "2.1.6"
edition = "2021"
rust-version = "1.80"
license = "MIT"
Expand Down
43 changes: 35 additions & 8 deletions crates/codegraph-docs/src/parsers/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::ir::{ByteSpan, Document, Kind, Node, Scalar};
use anyhow::Result;
use serde::Deserialize;
use std::collections::HashMap;

/// Generic document parser: turns a raw source file into the normalized
Expand Down Expand Up @@ -137,14 +138,25 @@ impl DocParser for YamlParser {
}

fn parse(&self, path: &str, source: &str, id: u64) -> Result<Document> {
let value: serde_yaml::Value = serde_yaml::from_str(source)?;
let root = convert_yaml_value(
&value,
ByteSpan {
start: 0,
end: source.len() as u64,
},
);
// File YAML được phép chứa nhiều document (`---`), vd k8s manifest.
let mut values: Vec<serde_yaml::Value> = Vec::new();
for doc in serde_yaml::Deserializer::from_str(source) {
values.push(serde_yaml::Value::deserialize(doc)?);
}
let span = ByteSpan {
start: 0,
end: source.len() as u64,
};
let root = match values.len() {
0 => RecursiveNode::Null(span),
1 => convert_yaml_value(&values[0], span),
_ => RecursiveNode::Array(
values
.iter()
.map(|v| (convert_yaml_value(v, ByteSpan { start: 0, end: 0 }), span))
.collect(),
),
};
Ok(build_document(
path.to_string(),
self.format().to_string(),
Expand Down Expand Up @@ -739,6 +751,21 @@ service:
assert_eq!(doc.nodes.len(), 4); // root, service, name, replicas
}

#[test]
fn yaml_parser_multi_document() {
let src = "---\nkind: Service\nname: api\n---\nkind: Deployment\nname: web\n";
let doc = YamlParser.parse("/tmp/multi.yaml", src, 1).unwrap();
// root (Array của 2 doc) + 2 doc + 4 trường con
assert_eq!(doc.nodes.len(), 7);
assert_eq!(
doc.nodes
.iter()
.filter(|n| n.key == Some("kind".into()))
.count(),
2
);
}

#[test]
fn nginx_parser_nested_blocks_and_directives() {
let src = r#"
Expand Down
2 changes: 1 addition & 1 deletion packaging/aur/codegraph-rs-bin/PKGBUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Maintainer: Hung Pham <hung0913208@icloud.com>
pkgname=codegraph-rs-bin
pkgver=2.1.5
pkgver=2.1.6
pkgrel=1
pkgdesc="Local-first code intelligence: tree-sitter knowledge graph + MCP server (prebuilt binary)"
arch=('x86_64' 'aarch64')
Expand Down
2 changes: 1 addition & 1 deletion packaging/choco/codegraph.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<id>codegraph</id>
<version>2.1.5</version>
<version>2.1.6</version>
<title>codegraph</title>
<authors>Hung Pham</authors>
<projectUrl>https://github.com/hungpham10/codegraph-rs</projectUrl>
Expand Down
4 changes: 2 additions & 2 deletions packaging/winget/codegraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# release time (or automate it in the release pipeline before submitting to
# microsoft/winget-pkgs).
PackageIdentifier: hungpham10.codegraph
PackageVersion: 2.1.5
PackageVersion: 2.1.6
PackageName: codegraph
Publisher: Hung Pham
PublisherUrl: https://github.com/hungpham10/codegraph-rs
Expand All @@ -18,7 +18,7 @@ PackageUrl: https://github.com/hungpham10/codegraph-rs
InstallerType: zip
Installers:
- Architecture: x64
InstallerUrl: https://github.com/hungpham10/codegraph-rs/releases/download/v2.1.5/codegraph-x86_64-pc-windows-msvc.zip
InstallerUrl: https://github.com/hungpham10/codegraph-rs/releases/download/v2.1.6/codegraph-x86_64-pc-windows-msvc.zip
InstallerSha256: 0000000000000000000000000000000000000000000000000000000000000000
InstallerType: zip
ManifestType: singleton
Expand Down
4 changes: 2 additions & 2 deletions scripts/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
#
# Usage (pin a version / download the script first):
# irm https://raw.githubusercontent.com/hungpham10/codegraph-rs/main/scripts/install.ps1 -OutFile install.ps1
# .\install.ps1 -Version 2.1.5
# .\install.ps1 -Version 2.1.6

[CmdletBinding()]
param(
# Pin a specific version, e.g. "2.1.5". Empty = latest release.
# Pin a specific version, e.g. "2.1.6". Empty = latest release.
[string]$Version
)

Expand Down
Loading