@@ -30,7 +30,10 @@ describe('git-revision-webpack-plugin (integration)', function () {
3030 config . context = targetProject
3131 config . output . path = targetBuild
3232 config . plugins = [
33- new GitRevisionPlugin ( { gitWorkTree : targetProject } )
33+ new GitRevisionPlugin ( {
34+ gitWorkTree : targetProject ,
35+ branch : true
36+ } )
3437 ]
3538
3639 webpack ( config , function ( ) {
@@ -108,7 +111,11 @@ describe('git-revision-webpack-plugin with lightweightTags option', function ()
108111 config . context = targetProject
109112 config . output . path = targetBuild
110113 config . plugins = [
111- new GitRevisionPlugin ( { gitWorkTree : targetProject , lightweightTags : true } )
114+ new GitRevisionPlugin ( {
115+ gitWorkTree : targetProject ,
116+ lightweightTags : true ,
117+ branch : true
118+ } )
112119 ]
113120
114121 webpack ( config , function ( ) {
@@ -170,3 +177,48 @@ describe('git-revision-webpack-plugin with lightweightTags option', function ()
170177 } )
171178 } )
172179} )
180+
181+ describe ( 'git-revision-webpack-plugin without branch option' , function ( ) {
182+ beforeEach ( function ( done ) {
183+ fs . emptyDirSync ( targetProject )
184+ fs . copySync ( sourceProject , targetProject )
185+
186+ fs . emptyDirSync ( targetGitRepository )
187+ fs . copySync ( sourceGitRepository , targetGitRepository )
188+
189+ fs . remove ( targetBuild )
190+
191+ var config = require ( targetProjectConfig )
192+
193+ config . context = targetProject
194+ config . output . path = targetBuild
195+ config . plugins = [
196+ new GitRevisionPlugin ( {
197+ gitWorkTree : targetProject
198+ } )
199+ ]
200+
201+ webpack ( config , function ( ) {
202+ done ( )
203+ } )
204+ } )
205+
206+ it ( 'should create the VERSION file' , function ( ) {
207+ var versionPath = path . join ( targetBuild , 'VERSION' )
208+ var VERSION = fs . readFileSync ( versionPath )
209+
210+ expect ( VERSION . toString ( ) ) . to . eql ( 'v1.0.0-1-g9a15b3b' )
211+ } )
212+
213+ it ( 'should create the COMMITHASH file' , function ( ) {
214+ var versionPath = path . join ( targetBuild , 'COMMITHASH' )
215+ var COMMITHASH = fs . readFileSync ( versionPath )
216+
217+ expect ( COMMITHASH . toString ( ) ) . to . eql ( '9a15b3ba1f8c347f9db94bcfde9630ed4fdeb1b2' )
218+ } )
219+
220+ it ( 'should not create the BRANCH file' , function ( ) {
221+ var branchPath = path . join ( targetBuild , 'BRANCH' )
222+ expect ( fs . existsSync ( branchPath ) ) . to . eql ( false )
223+ } )
224+ } )
0 commit comments