@@ -15,9 +15,9 @@ fn main() {
1515 let args: Vec < String > = env:: args ( ) . collect ( ) ;
1616 let mut patterns_filters: Vec < PatternFilter > = Vec :: new ( ) ;
1717
18- for arg in args. iter ( ) {
18+ for arg in & args {
1919 if arg. starts_with ( "--patterns=" ) {
20- patterns_filters = create_patterns_filters ( & arg) ;
20+ patterns_filters = create_patterns_filters ( arg) ;
2121 }
2222 }
2323
@@ -26,34 +26,34 @@ fn main() {
2626 return ;
2727 }
2828
29- let ( include_patterns_filters, exclude_patterns_filters) = categorize_filters ( patterns_filters) ;
29+ let ( include_patterns_filters, exclude_patterns_filters) = categorize_filters ( & patterns_filters) ;
3030
3131 let start = Instant :: now ( ) ;
3232 let changed_files = get_changed_files ( ) ;
3333 let duration = start. elapsed ( ) ;
34- println ! ( "Getting changed files done in: {:?}" , duration ) ;
34+ println ! ( "Getting changed files done in: {duration :?}" ) ;
3535
36- println ! ( "Changed files: {:?}" , changed_files ) ;
36+ println ! ( "Changed files: {changed_files :?}" ) ;
3737
3838 let start = Instant :: now ( ) ;
39- let filtered_files = filter_files ( changed_files, include_patterns_filters, exclude_patterns_filters) ;
39+ let filtered_files = filter_files ( & changed_files, & include_patterns_filters, & exclude_patterns_filters) ;
4040 let duration = start. elapsed ( ) ;
41- println ! ( "Filtering files done in: {:?}" , duration ) ;
41+ println ! ( "Filtering files done in: {duration :?}" ) ;
4242
43- let count = get_count ( filtered_files. clone ( ) ) ;
43+ let count = get_count ( & filtered_files) ;
4444
45- println ! ( "Filtered files: {:?}" , filtered_files ) ;
46- println ! ( "Count: {}" , count ) ;
45+ println ! ( "Filtered files: {filtered_files :?}" ) ;
46+ println ! ( "Count: {count}" ) ;
4747
4848 Command :: new ( "sh" )
4949 . arg ( "-c" )
50- . arg ( format ! ( "echo \" DIFF_FILES={:?}\" >> $GITHUB_OUTPUT" , filtered_files ) )
50+ . arg ( format ! ( "echo \" DIFF_FILES={filtered_files :?}\" >> $GITHUB_OUTPUT" ) )
5151 . output ( )
5252 . expect ( "Failed to execute DIFF_FILES command" ) ;
5353
5454 Command :: new ( "sh" )
5555 . arg ( "-c" )
56- . arg ( format ! ( "echo \" DIFF_COUNT={}\" >> $GITHUB_OUTPUT" , count ) )
56+ . arg ( format ! ( "echo \" DIFF_COUNT={count }\" >> $GITHUB_OUTPUT" ) )
5757 . output ( )
5858 . expect ( "Failed to execute DIFF_COUNT command" ) ;
5959}
@@ -63,9 +63,9 @@ fn create_patterns_filters(arg: &str) -> Vec<PatternFilter> {
6363 . split ( '=' )
6464 . last ( )
6565 . expect ( "Failed to get patterns" )
66- . replace ( " " , "" )
67- . replace ( " \n " , "," )
68- . replace ( " \r " , "" )
66+ . replace ( ' ' , "" )
67+ . replace ( '\n' , "," )
68+ . replace ( '\r' , "" )
6969 . replace ( ",," , "," )
7070 . trim_end_matches ( ',' )
7171 . to_string ( ) ;
@@ -76,12 +76,12 @@ fn create_patterns_filters(arg: &str) -> Vec<PatternFilter> {
7676
7777 let mut patterns_filters: Vec < PatternFilter > = Vec :: new ( ) ;
7878
79- for pattern in patterns. iter ( ) {
79+ for pattern in & patterns {
8080 let exclude = pattern. starts_with ( '!' ) ;
8181 let pattern = if exclude {
8282 pattern[ 1 ..] . to_string ( )
8383 } else {
84- pattern. to_string ( )
84+ ( * pattern) . to_string ( )
8585 } ;
8686
8787 patterns_filters. push ( PatternFilter {
@@ -104,11 +104,11 @@ fn get_changed_files() -> Vec<String> {
104104
105105 Command :: new ( "sh" )
106106 . arg ( "-c" )
107- . arg ( format ! ( "git fetch origin {}" , base_ref_env ) )
107+ . arg ( format ! ( "git fetch origin {base_ref_env}" ) )
108108 . output ( )
109109 . expect ( "Failed to execute fetch branch command" ) ;
110110
111- let base_ref_string = format ! ( "refs/remotes/origin/{}" , base_ref_env ) ;
111+ let base_ref_string = format ! ( "refs/remotes/origin/{base_ref_env}" ) ;
112112 let base_ref = repository. find_reference ( & base_ref_string) . expect ( "Failed to find default branch" ) ;
113113 let base_commit = base_ref. peel_to_commit ( ) . expect ( "Failed to peel default branch to commit" ) ;
114114
@@ -134,41 +134,41 @@ fn get_changed_files() -> Vec<String> {
134134 changed_files
135135}
136136
137- fn filter_files ( changed_files : Vec < String > , include_patterns_filters : HashSet < String > , exclude_patterns_filters : HashSet < String > ) -> HashSet < String > {
137+ fn filter_files ( changed_files : & Vec < String > , include_patterns_filters : & HashSet < String > , exclude_patterns_filters : & HashSet < String > ) -> HashSet < String > {
138138 let mut hash_set_filtered_files = HashSet :: new ( ) ;
139139
140- for changed_file in changed_files. iter ( ) {
141- include_patterns_filters . iter ( ) . for_each ( | pattern| {
140+ for changed_file in changed_files {
141+ for pattern in include_patterns_filters {
142142 if Pattern :: new ( pattern) . expect ( "Failed to create pattern" ) . matches ( changed_file) {
143143 hash_set_filtered_files. insert ( changed_file. to_string ( ) ) ;
144144 }
145145
146- exclude_patterns_filters . iter ( ) . for_each ( | pattern| {
146+ for pattern in exclude_patterns_filters {
147147 if Pattern :: new ( pattern) . expect ( "Failed to create pattern" ) . matches ( changed_file) {
148148 hash_set_filtered_files. remove ( changed_file) ;
149149 }
150- } ) ;
151- } ) ;
150+ }
151+ }
152152 }
153153
154154 hash_set_filtered_files
155155}
156156
157- fn get_count ( filtered_files : HashSet < String > ) -> usize {
157+ fn get_count ( filtered_files : & HashSet < String > ) -> usize {
158158 filtered_files. len ( )
159159}
160160
161- fn categorize_filters ( filters : Vec < PatternFilter > ) -> ( HashSet < String > , HashSet < String > ) {
161+ fn categorize_filters ( filters : & Vec < PatternFilter > ) -> ( HashSet < String > , HashSet < String > ) {
162162 let mut exclude_patterns_filters: HashSet < String > = HashSet :: new ( ) ;
163163 let mut include_patterns_filters: HashSet < String > = HashSet :: new ( ) ;
164164
165- filters . iter ( ) . for_each ( | pattern_filter| {
165+ for pattern_filter in filters {
166166 if pattern_filter. exclude {
167167 exclude_patterns_filters. insert ( pattern_filter. clone ( ) . pattern ) ;
168168 } else {
169169 include_patterns_filters. insert ( pattern_filter. clone ( ) . pattern ) ;
170170 }
171- } ) ;
171+ }
172172
173173 ( include_patterns_filters, exclude_patterns_filters)
174174}
0 commit comments