@@ -117,12 +117,12 @@ describe('CommitController', function() {
117117 } ) ;
118118
119119 describe ( 'committing' , function ( ) {
120- let workdirPath , repository ;
120+ let workdirPath , repository , commit ;
121121
122122 beforeEach ( async function ( ) {
123123 workdirPath = await cloneRepository ( 'three-files' ) ;
124124 repository = await buildRepositoryWithPipeline ( workdirPath , { confirm, notificationManager, workspace} ) ;
125- const commit = message => repository . commit ( message ) ;
125+ commit = sinon . stub ( ) . callsFake ( ( ... args ) => repository . commit ( ... args ) ) ;
126126
127127 app = React . cloneElement ( app , { repository, commit} ) ;
128128 } ) ;
@@ -139,6 +139,20 @@ describe('CommitController', function() {
139139 assert . strictEqual ( repository . getCommitMessage ( ) , '' ) ;
140140 } ) ;
141141
142+ it ( 'sets the verbatim flag when committing from the mini editor' , async function ( ) {
143+ await fs . writeFile ( path . join ( workdirPath , 'a.txt' ) , 'some changes' , { encoding : 'utf8' } ) ;
144+ await repository . git . exec ( [ 'add' , '.' ] ) ;
145+
146+ const wrapper = shallow ( app , { disableLifecycleMethods : true } ) ;
147+ await wrapper . instance ( ) . commit ( 'message\n\n#123 do some things' ) ;
148+
149+ assert . isTrue ( commit . calledWith ( 'message\n\n#123 do some things' , {
150+ amend : false ,
151+ coAuthors : [ ] ,
152+ verbatim : true ,
153+ } ) ) ;
154+ } ) ;
155+
142156 it ( 'issues a notification on failure' , async function ( ) {
143157 repository . setCommitMessage ( 'some message' ) ;
144158
@@ -159,44 +173,58 @@ describe('CommitController', function() {
159173 } ) ;
160174
161175 describe ( 'message formatting' , function ( ) {
162- let commitSpy ;
176+ let commitSpy , wrapper ;
177+
163178 beforeEach ( function ( ) {
164179 commitSpy = sinon . stub ( ) . returns ( Promise . resolve ( ) ) ;
165180 app = React . cloneElement ( app , { commit : commitSpy } ) ;
181+ wrapper = shallow ( app , { disableLifecycleMethods : true } ) ;
166182 } ) ;
167183
168- it ( 'wraps the commit message body at 72 characters if github.automaticCommitMessageWrapping is true' , async function ( ) {
169- config . set ( 'github.automaticCommitMessageWrapping' , false ) ;
184+ describe ( 'with automatic wrapping disabled' , function ( ) {
185+ beforeEach ( function ( ) {
186+ config . set ( 'github.automaticCommitMessageWrapping' , false ) ;
187+ } ) ;
170188
171- const wrapper = shallow ( app , { disableLifecycleMethods : true } ) ;
189+ it ( 'passes commit messages through unchanged' , async function ( ) {
190+ await wrapper . instance ( ) . commit ( [
191+ 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor' ,
192+ '' ,
193+ 'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.' ,
194+ ] . join ( '\n' ) ) ;
195+
196+ assert . strictEqual ( commitSpy . args [ 0 ] [ 0 ] , [
197+ 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor' ,
198+ '' ,
199+ 'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.' ,
200+ ] . join ( '\n' ) ) ;
201+ } ) ;
202+ } ) ;
172203
173- await wrapper . instance ( ) . commit ( [
174- 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor' ,
175- '' ,
176- 'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.' ,
177- ] . join ( '\n' ) ) ;
178-
179- assert . deepEqual ( commitSpy . args [ 0 ] [ 0 ] . split ( '\n' ) , [
180- 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor' ,
181- '' ,
182- 'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.' ,
183- ] ) ;
184-
185- commitSpy . reset ( ) ;
186- config . set ( 'github.automaticCommitMessageWrapping' , true ) ;
187-
188- await wrapper . instance ( ) . commit ( [
189- 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor' ,
190- '' ,
191- 'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.' ,
192- ] . join ( '\n' ) ) ;
193-
194- assert . deepEqual ( commitSpy . args [ 0 ] [ 0 ] . split ( '\n' ) , [
195- 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor' ,
196- '' ,
197- 'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ' ,
198- 'ut aliquip ex ea commodo consequat.' ,
199- ] ) ;
204+ describe ( 'with automatic wrapping enabled' , function ( ) {
205+ beforeEach ( function ( ) {
206+ config . set ( 'github.automaticCommitMessageWrapping' , true ) ;
207+ } ) ;
208+
209+ it ( 'wraps lines within the commit body at 72 characters' , async function ( ) {
210+ await wrapper . instance ( ) . commit ( [
211+ 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor' ,
212+ '' ,
213+ 'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.' ,
214+ ] . join ( '\n' ) ) ;
215+
216+ assert . strictEqual ( commitSpy . args [ 0 ] [ 0 ] , [
217+ 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor' ,
218+ '' ,
219+ 'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ' ,
220+ 'ut aliquip ex ea commodo consequat.' ,
221+ ] . join ( '\n' ) ) ;
222+ } ) ;
223+
224+ it ( 'preserves existing line wraps within the commit body' , async function ( ) {
225+ await wrapper . instance ( ) . commit ( 'a\n\nb\n\nc' ) ;
226+ assert . strictEqual ( commitSpy . args [ 0 ] [ 0 ] , 'a\n\nb\n\nc' ) ;
227+ } ) ;
200228 } ) ;
201229 } ) ;
202230
@@ -292,10 +320,14 @@ describe('CommitController', function() {
292320 const editor = workspace . getActiveTextEditor ( ) ;
293321 editor . setText ( 'message in editor' ) ;
294322 await editor . save ( ) ;
295- wrapper . find ( 'CommitView' ) . prop ( 'commit' ) ( 'message in box' ) ;
296323
297- await assert . async . strictEqual ( ( await repository . getLastCommit ( ) ) . getMessageSubject ( ) , 'message in editor' ) ;
298- await assert . async . isFalse ( fs . existsSync ( wrapper . instance ( ) . getCommitMessagePath ( ) ) ) ;
324+ await wrapper . find ( 'CommitView' ) . prop ( 'commit' ) ( 'message in box' ) ;
325+
326+ assert . strictEqual ( ( await repository . getLastCommit ( ) ) . getMessageSubject ( ) , 'message in editor' ) ;
327+ assert . isFalse ( fs . existsSync ( wrapper . instance ( ) . getCommitMessagePath ( ) ) ) ;
328+ assert . isTrue ( commit . calledWith ( 'message in editor' , {
329+ amend : false , coAuthors : [ ] , verbatim : false ,
330+ } ) ) ;
299331 } ) ;
300332
301333 it ( 'asks user to confirm if commit editor has unsaved changes' , async function ( ) {
0 commit comments