@@ -114,12 +114,12 @@ describe('CommitController', function() {
114114 } ) ;
115115
116116 describe ( 'committing' , function ( ) {
117- let workdirPath , repository ;
117+ let workdirPath , repository , commit ;
118118
119119 beforeEach ( async function ( ) {
120120 workdirPath = await cloneRepository ( 'three-files' ) ;
121121 repository = await buildRepositoryWithPipeline ( workdirPath , { confirm, notificationManager, workspace} ) ;
122- const commit = message => repository . commit ( message ) ;
122+ commit = sinon . stub ( ) . callsFake ( ( ... args ) => repository . commit ( ... args ) ) ;
123123
124124 app = React . cloneElement ( app , { repository, commit} ) ;
125125 } ) ;
@@ -136,6 +136,20 @@ describe('CommitController', function() {
136136 assert . strictEqual ( repository . getCommitMessage ( ) , '' ) ;
137137 } ) ;
138138
139+ it ( 'sets the verbatim flag when committing from the mini editor' , async function ( ) {
140+ await fs . writeFile ( path . join ( workdirPath , 'a.txt' ) , 'some changes' , { encoding : 'utf8' } ) ;
141+ await repository . git . exec ( [ 'add' , '.' ] ) ;
142+
143+ const wrapper = shallow ( app , { disableLifecycleMethods : true } ) ;
144+ await wrapper . instance ( ) . commit ( 'message\n\n#123 do some things' ) ;
145+
146+ assert . isTrue ( commit . calledWith ( 'message\n\n#123 do some things' , {
147+ amend : false ,
148+ coAuthors : [ ] ,
149+ verbatim : true ,
150+ } ) ) ;
151+ } ) ;
152+
139153 it ( 'issues a notification on failure' , async function ( ) {
140154 repository . setCommitMessage ( 'some message' ) ;
141155
@@ -156,44 +170,58 @@ describe('CommitController', function() {
156170 } ) ;
157171
158172 describe ( 'message formatting' , function ( ) {
159- let commitSpy ;
173+ let commitSpy , wrapper ;
174+
160175 beforeEach ( function ( ) {
161176 commitSpy = sinon . stub ( ) . returns ( Promise . resolve ( ) ) ;
162177 app = React . cloneElement ( app , { commit : commitSpy } ) ;
178+ wrapper = shallow ( app , { disableLifecycleMethods : true } ) ;
163179 } ) ;
164180
165- it ( 'wraps the commit message body at 72 characters if github.automaticCommitMessageWrapping is true' , async function ( ) {
166- config . set ( 'github.automaticCommitMessageWrapping' , false ) ;
181+ describe ( 'with automatic wrapping disabled' , function ( ) {
182+ beforeEach ( function ( ) {
183+ config . set ( 'github.automaticCommitMessageWrapping' , false ) ;
184+ } ) ;
167185
168- const wrapper = shallow ( app , { disableLifecycleMethods : true } ) ;
186+ it ( 'passes commit messages through unchanged' , async function ( ) {
187+ await wrapper . instance ( ) . commit ( [
188+ 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor' ,
189+ '' ,
190+ 'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.' ,
191+ ] . join ( '\n' ) ) ;
192+
193+ assert . strictEqual ( commitSpy . args [ 0 ] [ 0 ] , [
194+ 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor' ,
195+ '' ,
196+ 'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.' ,
197+ ] . join ( '\n' ) ) ;
198+ } ) ;
199+ } ) ;
169200
170- await wrapper . instance ( ) . commit ( [
171- 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor' ,
172- '' ,
173- 'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.' ,
174- ] . join ( '\n' ) ) ;
175-
176- assert . deepEqual ( commitSpy . args [ 0 ] [ 0 ] . split ( '\n' ) , [
177- 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor' ,
178- '' ,
179- 'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.' ,
180- ] ) ;
181-
182- commitSpy . reset ( ) ;
183- config . set ( 'github.automaticCommitMessageWrapping' , true ) ;
184-
185- await wrapper . instance ( ) . commit ( [
186- 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor' ,
187- '' ,
188- 'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.' ,
189- ] . join ( '\n' ) ) ;
190-
191- assert . deepEqual ( commitSpy . args [ 0 ] [ 0 ] . split ( '\n' ) , [
192- 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor' ,
193- '' ,
194- 'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ' ,
195- 'ut aliquip ex ea commodo consequat.' ,
196- ] ) ;
201+ describe ( 'with automatic wrapping enabled' , function ( ) {
202+ beforeEach ( function ( ) {
203+ config . set ( 'github.automaticCommitMessageWrapping' , true ) ;
204+ } ) ;
205+
206+ it ( 'wraps lines within the commit body at 72 characters' , async function ( ) {
207+ await wrapper . instance ( ) . commit ( [
208+ 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor' ,
209+ '' ,
210+ 'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.' ,
211+ ] . join ( '\n' ) ) ;
212+
213+ assert . strictEqual ( commitSpy . args [ 0 ] [ 0 ] , [
214+ 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor' ,
215+ '' ,
216+ 'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ' ,
217+ 'ut aliquip ex ea commodo consequat.' ,
218+ ] . join ( '\n' ) ) ;
219+ } ) ;
220+
221+ it ( 'preserves existing line wraps within the commit body' , async function ( ) {
222+ await wrapper . instance ( ) . commit ( 'a\n\nb\n\nc' ) ;
223+ assert . strictEqual ( commitSpy . args [ 0 ] [ 0 ] , 'a\n\nb\n\nc' ) ;
224+ } ) ;
197225 } ) ;
198226 } ) ;
199227
@@ -289,10 +317,14 @@ describe('CommitController', function() {
289317 const editor = workspace . getActiveTextEditor ( ) ;
290318 editor . setText ( 'message in editor' ) ;
291319 await editor . save ( ) ;
292- wrapper . find ( 'CommitView' ) . prop ( 'commit' ) ( 'message in box' ) ;
293320
294- await assert . async . strictEqual ( ( await repository . getLastCommit ( ) ) . getMessageSubject ( ) , 'message in editor' ) ;
295- await assert . async . isFalse ( fs . existsSync ( wrapper . instance ( ) . getCommitMessagePath ( ) ) ) ;
321+ await wrapper . find ( 'CommitView' ) . prop ( 'commit' ) ( 'message in box' ) ;
322+
323+ assert . strictEqual ( ( await repository . getLastCommit ( ) ) . getMessageSubject ( ) , 'message in editor' ) ;
324+ assert . isFalse ( fs . existsSync ( wrapper . instance ( ) . getCommitMessagePath ( ) ) ) ;
325+ assert . isTrue ( commit . calledWith ( 'message in editor' , {
326+ amend : false , coAuthors : [ ] , verbatim : false ,
327+ } ) ) ;
296328 } ) ;
297329
298330 it ( 'asks user to confirm if commit editor has unsaved changes' , async function ( ) {
0 commit comments