@@ -14,6 +14,7 @@ import {
14
14
gitRemoteTagHead ,
15
15
push ,
16
16
gitShallowClone ,
17
+ reset ,
17
18
} from './helpers/git-utils' ;
18
19
19
20
// Save the current process.env
@@ -57,6 +58,7 @@ test.serial('Plugins are called with expected values', async t => {
57
58
await gitTagVersion ( 'v1.0.0' ) ;
58
59
// Add new commits to the master branch
59
60
commits = ( await gitCommits ( [ 'Second' ] ) ) . concat ( commits ) ;
61
+ await push ( ) ;
60
62
61
63
const lastRelease = { version : '1.0.0' , gitHead : commits [ commits . length - 1 ] . hash , gitTag : 'v1.0.0' } ;
62
64
const nextRelease = { type : 'major' , version : '2.0.0' , gitHead : await getGitHead ( ) , gitTag : 'v2.0.0' } ;
@@ -162,6 +164,7 @@ test.serial('Use custom tag format', async t => {
162
164
await gitCommits ( [ 'First' ] ) ;
163
165
await gitTagVersion ( 'test-1.0.0' ) ;
164
166
await gitCommits ( [ 'Second' ] ) ;
167
+ await push ( ) ;
165
168
166
169
const nextRelease = { type : 'major' , version : '2.0.0' , gitHead : await getGitHead ( ) , gitTag : 'test-2.0.0' } ;
167
170
const notes = 'Release notes' ;
@@ -198,6 +201,7 @@ test.serial('Use new gitHead, and recreate release notes if a prepare plugin cre
198
201
await gitTagVersion ( 'v1.0.0' ) ;
199
202
// Add new commits to the master branch
200
203
commits = ( await gitCommits ( [ 'Second' ] ) ) . concat ( commits ) ;
204
+ await push ( ) ;
201
205
202
206
const nextRelease = { type : 'major' , version : '2.0.0' , gitHead : await getGitHead ( ) , gitTag : 'v2.0.0' } ;
203
207
const notes = 'Release notes' ;
@@ -257,6 +261,7 @@ test.serial('Call all "success" plugins even if one errors out', async t => {
257
261
await gitTagVersion ( 'v1.0.0' ) ;
258
262
// Add new commits to the master branch
259
263
await gitCommits ( [ 'Second' ] ) ;
264
+ await push ( ) ;
260
265
261
266
const nextRelease = { type : 'major' , version : '2.0.0' , gitHead : await getGitHead ( ) , gitTag : 'v2.0.0' } ;
262
267
const notes = 'Release notes' ;
@@ -304,6 +309,7 @@ test.serial('Log all "verifyConditions" errors', async t => {
304
309
const repositoryUrl = await gitRepo ( true ) ;
305
310
// Add commits to the master branch
306
311
await gitCommits ( [ 'First' ] ) ;
312
+ await push ( ) ;
307
313
308
314
const error1 = new Error ( 'error 1' ) ;
309
315
const error2 = new SemanticReleaseError ( 'error 2' , 'ERR2' ) ;
@@ -346,6 +352,7 @@ test.serial('Log all "verifyRelease" errors', async t => {
346
352
await gitTagVersion ( 'v1.0.0' ) ;
347
353
// Add new commits to the master branch
348
354
await gitCommits ( [ 'Second' ] ) ;
355
+ await push ( ) ;
349
356
350
357
const error1 = new SemanticReleaseError ( 'error 1' , 'ERR1' ) ;
351
358
const error2 = new SemanticReleaseError ( 'error 2' , 'ERR2' ) ;
@@ -382,6 +389,7 @@ test.serial('Dry-run skips publish and success', async t => {
382
389
await gitTagVersion ( 'v1.0.0' ) ;
383
390
// Add new commits to the master branch
384
391
await gitCommits ( [ 'Second' ] ) ;
392
+ await push ( ) ;
385
393
386
394
const nextRelease = { type : 'major' , version : '2.0.0' , gitHead : await getGitHead ( ) , gitTag : 'v2.0.0' } ;
387
395
const notes = 'Release notes' ;
@@ -430,6 +438,7 @@ test.serial('Dry-run skips fail', async t => {
430
438
await gitTagVersion ( 'v1.0.0' ) ;
431
439
// Add new commits to the master branch
432
440
await gitCommits ( [ 'Second' ] ) ;
441
+ await push ( ) ;
433
442
434
443
const error1 = new SemanticReleaseError ( 'error 1' , 'ERR1' ) ;
435
444
const error2 = new SemanticReleaseError ( 'error 2' , 'ERR2' ) ;
@@ -464,6 +473,7 @@ test.serial('Force a dry-run if not on a CI and "noCi" is not explicitly set', a
464
473
await gitTagVersion ( 'v1.0.0' ) ;
465
474
// Add new commits to the master branch
466
475
await gitCommits ( [ 'Second' ] ) ;
476
+ await push ( ) ;
467
477
468
478
const nextRelease = { type : 'major' , version : '2.0.0' , gitHead : await getGitHead ( ) , gitTag : 'v2.0.0' } ;
469
479
const notes = 'Release notes' ;
@@ -513,6 +523,7 @@ test.serial('Allow local releases with "noCi" option', async t => {
513
523
await gitTagVersion ( 'v1.0.0' ) ;
514
524
// Add new commits to the master branch
515
525
await gitCommits ( [ 'Second' ] ) ;
526
+ await push ( ) ;
516
527
517
528
const nextRelease = { type : 'major' , version : '2.0.0' , gitHead : await getGitHead ( ) , gitTag : 'v2.0.0' } ;
518
529
const notes = 'Release notes' ;
@@ -566,6 +577,7 @@ test.serial('Accept "undefined" value returned by the "generateNotes" plugins',
566
577
await gitTagVersion ( 'v1.0.0' ) ;
567
578
// Add new commits to the master branch
568
579
commits = ( await gitCommits ( [ 'Second' ] ) ) . concat ( commits ) ;
580
+ await push ( ) ;
569
581
570
582
const lastRelease = { version : '1.0.0' , gitHead : commits [ commits . length - 1 ] . hash , gitTag : 'v1.0.0' } ;
571
583
const nextRelease = { type : 'major' , version : '2.0.0' , gitHead : await getGitHead ( ) , gitTag : 'v2.0.0' } ;
@@ -623,6 +635,27 @@ test.serial('Returns falsy value if triggered by a PR', async t => {
623
635
) ;
624
636
} ) ;
625
637
638
+ test . serial ( 'Returns falsy value if triggered on an outdated clone' , async t => {
639
+ // Create a git repository, set the current working directory at the root of the repo
640
+ const repositoryUrl = await gitRepo ( true ) ;
641
+ // Add commits to the master branch
642
+ await gitCommits ( [ 'First' ] ) ;
643
+ await gitCommits ( [ 'Second' ] ) ;
644
+ await push ( ) ;
645
+ await reset ( ) ;
646
+
647
+ const semanticRelease = proxyquire ( '..' , {
648
+ './lib/logger' : t . context . logger ,
649
+ 'env-ci' : ( ) => ( { isCi : true , branch : 'master' , isPr : false } ) ,
650
+ } ) ;
651
+
652
+ t . falsy ( await semanticRelease ( { repositoryUrl} ) ) ;
653
+ t . deepEqual ( t . context . log . args [ t . context . log . args . length - 1 ] , [
654
+ "The local branch %s is behind the remote one, therefore a new version won't be published." ,
655
+ 'master' ,
656
+ ] ) ;
657
+ } ) ;
658
+
626
659
test . serial ( 'Returns falsy value if not running from the configured branch' , async t => {
627
660
// Create a git repository, set the current working directory at the root of the repo
628
661
const repositoryUrl = await gitRepo ( true ) ;
@@ -656,6 +689,7 @@ test.serial('Returns falsy value if there is no relevant changes', async t => {
656
689
const repositoryUrl = await gitRepo ( true ) ;
657
690
// Add commits to the master branch
658
691
await gitCommits ( [ 'First' ] ) ;
692
+ await push ( ) ;
659
693
660
694
const analyzeCommits = stub ( ) . resolves ( ) ;
661
695
const verifyRelease = stub ( ) . resolves ( ) ;
@@ -685,7 +719,10 @@ test.serial('Returns falsy value if there is no relevant changes', async t => {
685
719
t . is ( verifyRelease . callCount , 0 ) ;
686
720
t . is ( generateNotes . callCount , 0 ) ;
687
721
t . is ( publish . callCount , 0 ) ;
688
- t . is ( t . context . log . args [ 7 ] [ 0 ] , 'There are no relevant changes, so no new version is released.' ) ;
722
+ t . is (
723
+ t . context . log . args [ t . context . log . args . length - 1 ] [ 0 ] ,
724
+ 'There are no relevant changes, so no new version is released.'
725
+ ) ;
689
726
} ) ;
690
727
691
728
test . serial ( 'Exclude commits with [skip release] or [release skip] from analysis' , async t => {
@@ -702,6 +739,7 @@ test.serial('Exclude commits with [skip release] or [release skip] from analysis
702
739
'Test commit\n\n commit body\n[skip release]' ,
703
740
'Test commit\n\n commit body\n[release skip]' ,
704
741
] ) ;
742
+ await push ( ) ;
705
743
const analyzeCommits = stub ( ) . resolves ( ) ;
706
744
const config = { branch : 'master' , repositoryUrl, globalOpt : 'global' } ;
707
745
const options = {
@@ -826,6 +864,7 @@ test.serial('Throw an Error if plugin returns an unexpected value', async t => {
826
864
await gitTagVersion ( 'v1.0.0' ) ;
827
865
// Add new commits to the master branch
828
866
await gitCommits ( [ 'Second' ] ) ;
867
+ await push ( ) ;
829
868
830
869
const verifyConditions = stub ( ) . resolves ( ) ;
831
870
const analyzeCommits = stub ( ) . resolves ( 'string' ) ;
0 commit comments