File tree Expand file tree Collapse file tree 3 files changed +20
-0
lines changed Expand file tree Collapse file tree 3 files changed +20
-0
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @changesets/ghcommit " : minor
3
+ ---
4
+
5
+ Introduce ` filterFiles ` argument for ` commitChangesFromRepo `
6
+
7
+ Allow for a custom function to be specified to filter which files should be
8
+ included in the commit
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ export const commitChangesFromRepo = async ({
21
21
base,
22
22
repoDirectory,
23
23
addFromDirectory,
24
+ filterFiles,
24
25
log,
25
26
...otherArgs
26
27
} : CommitChangesFromRepoArgs ) : Promise < CommitFilesResult > => {
@@ -86,6 +87,10 @@ export const commitChangesFromRepo = async ({
86
87
// Iterate through these directories
87
88
return true ;
88
89
}
90
+ if ( filterFiles && ! filterFiles ( filepath ) ) {
91
+ // Ignore out files that don't match any specified filter
92
+ return null ;
93
+ }
89
94
if ( ! workdir ) {
90
95
// File was deleted
91
96
deletions . push ( filepath ) ;
Original file line number Diff line number Diff line change @@ -120,4 +120,11 @@ export interface CommitChangesFromRepoArgs extends CommitFilesBasedArgs {
120
120
* which will add all changed files in the repository.
121
121
*/
122
122
addFromDirectory ?: string ;
123
+ /**
124
+ * An optional function that can be used to filter which files are included
125
+ * in the commit. True should be returned for files that should be included.
126
+ *
127
+ * By default, all files are included.
128
+ */
129
+ filterFiles ?: ( file : string ) => boolean ;
123
130
}
You can’t perform that action at this time.
0 commit comments