@@ -11,6 +11,7 @@ import rimraf from 'rimraf';
11
11
import expect from 'unexpected' ;
12
12
13
13
import getMessages from '../../source/library/get-messages' ;
14
+ import pkg from '../../package' ;
14
15
15
16
const rm = denodeify ( rimraf ) ;
16
17
@@ -60,6 +61,22 @@ test.serial('get edit commit message from git subdirectory', async () => {
60
61
await cleanRepository ( repo ) ;
61
62
} ) ;
62
63
64
+ test . serial ( 'get history commit messages from shallow clone' , async ( ) => {
65
+ const repo = await initRepository ( ) ;
66
+
67
+ await writeFile ( 'alpha.txt' , 'alpha' ) ;
68
+ await execa ( 'git' , [ 'add' , 'alpha.txt' ] ) ;
69
+ await execa ( 'git' , [ 'commit' , '-m' , 'alpha' ] ) ;
70
+
71
+ const clone = await cloneRepository ( pkg . repository . url , repo , '--depth' , '1' ) ;
72
+
73
+ const actual = async ( ) => await getMessages ( { from : 'master' } ) ;
74
+ expect ( actual , 'to error with' , / C o u l d n o t g e t g i t h i s t o r y f r o m s h a l l o w c l o n e / ) ;
75
+
76
+ await cleanRepository ( clone ) ;
77
+ await cleanRepository ( repo ) ;
78
+ } ) ;
79
+
63
80
async function initRepository ( ) {
64
81
const previous = process . cwd ( ) ;
65
82
const directory = join ( tmpdir ( ) , rand ( ) ) ;
@@ -74,6 +91,17 @@ async function initRepository() {
74
91
return { directory, previous} ;
75
92
}
76
93
94
+ async function cloneRepository ( source , context , ...args ) {
95
+ const directory = join ( tmpdir ( ) , rand ( ) ) ;
96
+ await execa ( 'git' , [ 'clone' , ...args , source , directory ] ) ;
97
+ process . chdir ( directory ) ;
98
+
99
+ await execa ( 'git' , [ 'config' , 'user.email' , '[email protected] ' ] ) ;
100
+ await execa ( 'git' , [ 'config' , 'user.name' , 'ava' ] ) ;
101
+
102
+ return { directory, previous : context . previous } ;
103
+ }
104
+
77
105
async function cleanRepository ( repo ) {
78
106
process . chdir ( repo . previous ) ;
79
107
0 commit comments