File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -82,7 +82,6 @@ fn read_chart_name(chart_dir: &std::path::Path) -> Result<String> {
8282 let raw = std:: fs:: read_to_string ( & chart_yaml)
8383 . with_context ( || format ! ( "read {}" , chart_yaml. display( ) ) ) ?;
8484 for line in raw. lines ( ) {
85- let line = line. trim ( ) ;
8685 if let Some ( rest) = line. strip_prefix ( "name:" ) {
8786 let value = rest. trim ( ) . trim_matches ( |c| c == '"' || c == '\'' ) ;
8887 if !value. is_empty ( ) {
@@ -175,4 +174,26 @@ mod tests {
175174 . unwrap ( ) ;
176175 assert ! ( read_chart_name( dir. path( ) ) . is_err( ) ) ;
177176 }
177+
178+ #[ test]
179+ fn read_chart_name_ignores_a_nested_name_before_the_chart_one ( ) {
180+ let dir = tempfile:: tempdir ( ) . unwrap ( ) ;
181+ std:: fs:: write (
182+ dir. path ( ) . join ( "Chart.yaml" ) ,
183+ "apiVersion: v2\n dependencies:\n - repository: oci://ghcr.io/x\n name: common\n version: 1.0.0\n maintainers:\n - name: Ops\n name: my-chart\n version: 0.1.0\n " ,
184+ )
185+ . unwrap ( ) ;
186+ assert_eq ! ( read_chart_name( dir. path( ) ) . unwrap( ) , "my-chart" ) ;
187+ }
188+
189+ #[ test]
190+ fn read_chart_name_handles_crlf_and_single_quotes ( ) {
191+ let dir = tempfile:: tempdir ( ) . unwrap ( ) ;
192+ std:: fs:: write (
193+ dir. path ( ) . join ( "Chart.yaml" ) ,
194+ "apiVersion: v2\r \n name: 'win-chart' \r \n version: 0.1.0\r \n " ,
195+ )
196+ . unwrap ( ) ;
197+ assert_eq ! ( read_chart_name( dir. path( ) ) . unwrap( ) , "win-chart" ) ;
198+ }
178199}
You can’t perform that action at this time.
0 commit comments