@@ -18,6 +18,7 @@ interface ObsidianGitSettings {
18
18
disablePush : boolean ;
19
19
pullBeforePush : boolean ;
20
20
disablePopups : boolean ;
21
+ listChangedFilesInMessageBody : boolean ;
21
22
}
22
23
const DEFAULT_SETTINGS : ObsidianGitSettings = {
23
24
commitMessage : "vault backup: {{date}}" ,
@@ -27,6 +28,7 @@ const DEFAULT_SETTINGS: ObsidianGitSettings = {
27
28
disablePush : false ,
28
29
pullBeforePush : true ,
29
30
disablePopups : false ,
31
+ listChangedFilesInMessageBody : false ,
30
32
} ;
31
33
32
34
export default class ObsidianGit extends Plugin {
@@ -219,7 +221,10 @@ export default class ObsidianGit extends Plugin {
219
221
220
222
async commit ( message ?: string ) : Promise < void > {
221
223
this . setState ( PluginState . commit ) ;
222
- const commitMessage = message ?? await this . formatCommitMessage ( this . settings . commitMessage ) ;
224
+ let commitMessage : string | string [ ] = message ?? await this . formatCommitMessage ( this . settings . commitMessage ) ;
225
+ if ( this . settings . listChangedFilesInMessageBody ) {
226
+ commitMessage = [ commitMessage , "Affected files:" , ( await this . git . status ( ) ) . staged . join ( "\n" ) ] ;
227
+ }
223
228
await this . git . commit ( commitMessage ) ;
224
229
}
225
230
@@ -403,6 +408,17 @@ class ObsidianGitSettingsTab extends PluginSettingTab {
403
408
} )
404
409
) ;
405
410
411
+ new Setting ( containerEl )
412
+ . setName ( "List filenames affected by commit in the commit body" )
413
+ . addToggle ( ( toggle ) =>
414
+ toggle
415
+ . setValue ( plugin . settings . listChangedFilesInMessageBody )
416
+ . onChange ( ( value ) => {
417
+ plugin . settings . listChangedFilesInMessageBody = value ;
418
+ plugin . saveSettings ( ) ;
419
+ } )
420
+ ) ;
421
+
406
422
new Setting ( containerEl )
407
423
. setName ( "Current branch" )
408
424
. setDesc ( "Switch to a different branch" )
0 commit comments