@@ -104,12 +104,12 @@ describe('CommitController', function() {
104104 } ) ;
105105
106106 describe ( 'committing' , function ( ) {
107- let workdirPath , repository ;
107+ let workdirPath , repository , commit ;
108108
109109 beforeEach ( async function ( ) {
110110 workdirPath = await cloneRepository ( 'three-files' ) ;
111111 repository = await buildRepositoryWithPipeline ( workdirPath , { confirm, notificationManager, workspace} ) ;
112- const commit = message => repository . commit ( message ) ;
112+ commit = sinon . stub ( ) . callsFake ( ( ... args ) => repository . commit ( ... args ) ) ;
113113
114114 app = React . cloneElement ( app , { repository, commit} ) ;
115115 } ) ;
@@ -126,6 +126,20 @@ describe('CommitController', function() {
126126 assert . strictEqual ( repository . getCommitMessage ( ) , '' ) ;
127127 } ) ;
128128
129+ it ( 'sets the verbatim flag when committing from the mini editor' , async function ( ) {
130+ await fs . writeFile ( path . join ( workdirPath , 'a.txt' ) , 'some changes' , { encoding : 'utf8' } ) ;
131+ await repository . git . exec ( [ 'add' , '.' ] ) ;
132+
133+ const wrapper = shallow ( app , { disableLifecycleMethods : true } ) ;
134+ await wrapper . instance ( ) . commit ( 'message\n\n#123 do some things' ) ;
135+
136+ assert . isTrue ( commit . calledWith ( 'message\n\n#123 do some things' , {
137+ amend : false ,
138+ coAuthors : [ ] ,
139+ verbatim : true ,
140+ } ) ) ;
141+ } ) ;
142+
129143 it ( 'issues a notification on failure' , async function ( ) {
130144 repository . setCommitMessage ( 'some message' ) ;
131145
@@ -146,44 +160,58 @@ describe('CommitController', function() {
146160 } ) ;
147161
148162 describe ( 'message formatting' , function ( ) {
149- let commitSpy ;
163+ let commitSpy , wrapper ;
164+
150165 beforeEach ( function ( ) {
151166 commitSpy = sinon . stub ( ) . returns ( Promise . resolve ( ) ) ;
152167 app = React . cloneElement ( app , { commit : commitSpy } ) ;
168+ wrapper = shallow ( app , { disableLifecycleMethods : true } ) ;
153169 } ) ;
154170
155- it ( 'wraps the commit message body at 72 characters if github.automaticCommitMessageWrapping is true' , async function ( ) {
156- config . set ( 'github.automaticCommitMessageWrapping' , false ) ;
171+ describe ( 'with automatic wrapping disabled' , function ( ) {
172+ beforeEach ( function ( ) {
173+ config . set ( 'github.automaticCommitMessageWrapping' , false ) ;
174+ } ) ;
157175
158- const wrapper = shallow ( app ) ;
176+ it ( 'passes commit messages through unchanged' , async function ( ) {
177+ await wrapper . instance ( ) . commit ( [
178+ 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor' ,
179+ '' ,
180+ 'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.' ,
181+ ] . join ( '\n' ) ) ;
182+
183+ assert . strictEqual ( commitSpy . args [ 0 ] [ 0 ] , [
184+ 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor' ,
185+ '' ,
186+ 'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.' ,
187+ ] . join ( '\n' ) ) ;
188+ } ) ;
189+ } ) ;
159190
160- await wrapper . instance ( ) . commit ( [
161- 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor' ,
162- '' ,
163- 'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.' ,
164- ] . join ( '\n' ) ) ;
165-
166- assert . deepEqual ( commitSpy . args [ 0 ] [ 0 ] . split ( '\n' ) , [
167- 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor' ,
168- '' ,
169- 'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.' ,
170- ] ) ;
171-
172- commitSpy . reset ( ) ;
173- config . set ( 'github.automaticCommitMessageWrapping' , true ) ;
174-
175- await wrapper . instance ( ) . commit ( [
176- 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor' ,
177- '' ,
178- 'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.' ,
179- ] . join ( '\n' ) ) ;
180-
181- assert . deepEqual ( commitSpy . args [ 0 ] [ 0 ] . split ( '\n' ) , [
182- 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor' ,
183- '' ,
184- 'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ' ,
185- 'ut aliquip ex ea commodo consequat.' ,
186- ] ) ;
191+ describe ( 'with automatic wrapping enabled' , function ( ) {
192+ beforeEach ( function ( ) {
193+ config . set ( 'github.automaticCommitMessageWrapping' , true ) ;
194+ } ) ;
195+
196+ it ( 'wraps lines within the commit body at 72 characters' , async function ( ) {
197+ await wrapper . instance ( ) . commit ( [
198+ 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor' ,
199+ '' ,
200+ 'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.' ,
201+ ] . join ( '\n' ) ) ;
202+
203+ assert . strictEqual ( commitSpy . args [ 0 ] [ 0 ] , [
204+ 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor' ,
205+ '' ,
206+ 'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ' ,
207+ 'ut aliquip ex ea commodo consequat.' ,
208+ ] . join ( '\n' ) ) ;
209+ } ) ;
210+
211+ it ( 'preserves existing line wraps within the commit body' , async function ( ) {
212+ await wrapper . instance ( ) . commit ( 'a\n\nb\n\nc' ) ;
213+ assert . strictEqual ( commitSpy . args [ 0 ] [ 0 ] , 'a\n\nb\n\nc' ) ;
214+ } ) ;
187215 } ) ;
188216 } ) ;
189217
@@ -278,10 +306,14 @@ describe('CommitController', function() {
278306 const editor = workspace . getActiveTextEditor ( ) ;
279307 editor . setText ( 'message in editor' ) ;
280308 await editor . save ( ) ;
281- wrapper . find ( 'CommitView' ) . prop ( 'commit' ) ( 'message in box' ) ;
282309
283- await assert . async . strictEqual ( ( await repository . getLastCommit ( ) ) . getMessageSubject ( ) , 'message in editor' ) ;
284- await assert . async . isFalse ( fs . existsSync ( wrapper . instance ( ) . getCommitMessagePath ( ) ) ) ;
310+ await wrapper . find ( 'CommitView' ) . prop ( 'commit' ) ( 'message in box' ) ;
311+
312+ assert . strictEqual ( ( await repository . getLastCommit ( ) ) . getMessageSubject ( ) , 'message in editor' ) ;
313+ assert . isFalse ( fs . existsSync ( wrapper . instance ( ) . getCommitMessagePath ( ) ) ) ;
314+ assert . isTrue ( commit . calledWith ( 'message in editor' , {
315+ amend : false , coAuthors : [ ] , verbatim : false ,
316+ } ) ) ;
285317 } ) ;
286318
287319 it ( 'asks user to confirm if commit editor has unsaved changes' , async function ( ) {
0 commit comments