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 > => {
@@ -91,6 +92,10 @@ export const commitChangesFromRepo = async ({
91
92
// Iterate through these directories
92
93
return true ;
93
94
}
95
+ if ( filterFiles && ! filterFiles ( filepath ) ) {
96
+ // Ignore out files that don't match any specified filter
97
+ return null ;
98
+ }
94
99
if ( ! workdir ) {
95
100
// File was deleted
96
101
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