@@ -35,11 +35,39 @@ impl Config {
3535 pub fn save ( & self , path : & str ) -> Result < ( ) > {
3636 let yaml = serde_yaml:: to_string ( self ) ?;
3737
38- std:: fs:: write ( path, yaml) ?;
38+ // Fix indentation for yamllint compliance
39+ // yamllint expects array items to be indented relative to their parent
40+ let fixed_yaml = Self :: fix_yaml_indentation ( & yaml) ;
41+
42+ // Make yamllint compliant by adding document separator and ensuring newline at end
43+ let yaml_content = format ! ( "---\n {}\n " , fixed_yaml) ;
44+
45+ std:: fs:: write ( path, yaml_content) ?;
3946
4047 Ok ( ( ) )
4148 }
4249
50+ /// Fix YAML indentation to be yamllint compliant
51+ fn fix_yaml_indentation ( yaml : & str ) -> String {
52+ let lines: Vec < & str > = yaml. lines ( ) . collect ( ) ;
53+ let mut result = Vec :: new ( ) ;
54+
55+ for line in lines {
56+ // If line starts with a dash (array item), indent it by 2 spaces
57+ if line. starts_with ( "- " ) {
58+ result. push ( format ! ( " {}" , line) ) ;
59+ } else if line. starts_with ( " " ) && !line. starts_with ( " " ) {
60+ // If line is already indented by 2 spaces but not 4, make it 4 spaces
61+ // This handles the properties of array items
62+ result. push ( format ! ( " {}" , line) ) ;
63+ } else {
64+ result. push ( line. to_string ( ) ) ;
65+ }
66+ }
67+
68+ result. join ( "\n " )
69+ }
70+
4371 /// Filter repositories by specific names
4472 pub fn filter_by_names ( & self , names : & [ String ] ) -> Vec < Repository > {
4573 if names. is_empty ( ) {
0 commit comments