1
1
const execa = require ( 'execa' ) ;
2
2
const debug = require ( 'debug' ) ( 'semantic-release:git' ) ;
3
- const envCi = require ( 'env-ci' ) ;
4
-
5
- const timeout = envCi ( ) . isCi ? 10000 : 0 ;
6
3
7
4
/**
8
5
* Get the commit sha for a given tag.
@@ -13,7 +10,7 @@ const timeout = envCi().isCi ? 10000 : 0;
13
10
*/
14
11
async function gitTagHead ( tagName ) {
15
12
try {
16
- return await execa . stdout ( 'git' , [ 'rev-list' , '-1' , tagName ] , { timeout } ) ;
13
+ return await execa . stdout ( 'git' , [ 'rev-list' , '-1' , tagName ] ) ;
17
14
} catch ( err ) {
18
15
debug ( err ) ;
19
16
}
@@ -24,7 +21,7 @@ async function gitTagHead(tagName) {
24
21
* @throws {Error } If the `git` command fails.
25
22
*/
26
23
async function gitTags ( ) {
27
- return ( await execa . stdout ( 'git' , [ 'tag' ] , { timeout } ) )
24
+ return ( await execa . stdout ( 'git' , [ 'tag' ] ) )
28
25
. split ( '\n' )
29
26
. map ( tag => tag . trim ( ) )
30
27
. filter ( tag => Boolean ( tag ) ) ;
@@ -39,7 +36,7 @@ async function gitTags() {
39
36
*/
40
37
async function isRefInHistory ( ref ) {
41
38
try {
42
- return ( await execa ( 'git' , [ 'merge-base' , '--is-ancestor' , ref , 'HEAD' ] , { timeout } ) ) . code === 0 ;
39
+ return ( await execa ( 'git' , [ 'merge-base' , '--is-ancestor' , ref , 'HEAD' ] ) ) . code === 0 ;
43
40
} catch ( err ) {
44
41
debug ( err ) ;
45
42
}
@@ -49,22 +46,22 @@ async function isRefInHistory(ref) {
49
46
* Unshallow the git repository (retriving every commits and tags).
50
47
*/
51
48
async function unshallow ( ) {
52
- await execa ( 'git' , [ 'fetch' , '--unshallow' , '--tags' ] , { reject : false , timeout } ) ;
49
+ await execa ( 'git' , [ 'fetch' , '--unshallow' , '--tags' ] , { reject : false } ) ;
53
50
}
54
51
55
52
/**
56
53
* @return {string } the sha of the HEAD commit.
57
54
*/
58
55
async function gitHead ( ) {
59
- return execa . stdout ( 'git' , [ 'rev-parse' , 'HEAD' ] , { timeout } ) ;
56
+ return execa . stdout ( 'git' , [ 'rev-parse' , 'HEAD' ] ) ;
60
57
}
61
58
62
59
/**
63
60
* @return {string } The value of the remote git URL.
64
61
*/
65
62
async function repoUrl ( ) {
66
63
try {
67
- return await execa . stdout ( 'git' , [ 'remote' , 'get-url' , 'origin' ] , { timeout } ) ;
64
+ return await execa . stdout ( 'git' , [ 'remote' , 'get-url' , 'origin' ] ) ;
68
65
} catch ( err ) {
69
66
debug ( err ) ;
70
67
}
@@ -75,7 +72,7 @@ async function repoUrl() {
75
72
*/
76
73
async function isGitRepo ( ) {
77
74
try {
78
- return ( await execa ( 'git' , [ 'rev-parse' , '--git-dir' ] , { timeout } ) ) . code === 0 ;
75
+ return ( await execa ( 'git' , [ 'rev-parse' , '--git-dir' ] ) ) . code === 0 ;
79
76
} catch ( err ) {
80
77
debug ( err ) ;
81
78
}
@@ -91,7 +88,7 @@ async function isGitRepo() {
91
88
*/
92
89
async function verifyAuth ( origin , branch ) {
93
90
try {
94
- return ( await execa ( 'git' , [ 'push' , '--dry-run' , origin , `HEAD:${ branch } ` ] , { timeout } ) ) . code === 0 ;
91
+ return ( await execa ( 'git' , [ 'push' , '--dry-run' , origin , `HEAD:${ branch } ` ] ) ) . code === 0 ;
95
92
} catch ( err ) {
96
93
debug ( err ) ;
97
94
}
@@ -104,7 +101,7 @@ async function verifyAuth(origin, branch) {
104
101
* @throws {Error } if the tag creation failed.
105
102
*/
106
103
async function tag ( tagName ) {
107
- await execa ( 'git' , [ 'tag' , tagName ] , { timeout } ) ;
104
+ await execa ( 'git' , [ 'tag' , tagName ] ) ;
108
105
}
109
106
110
107
/**
@@ -115,7 +112,7 @@ async function tag(tagName) {
115
112
* @throws {Error } if the push failed.
116
113
*/
117
114
async function push ( origin , branch ) {
118
- await execa ( 'git' , [ 'push' , '--tags' , origin , `HEAD:${ branch } ` ] , { timeout } ) ;
115
+ await execa ( 'git' , [ 'push' , '--tags' , origin , `HEAD:${ branch } ` ] ) ;
119
116
}
120
117
121
118
/**
@@ -126,7 +123,7 @@ async function push(origin, branch) {
126
123
*/
127
124
async function verifyTagName ( tagName ) {
128
125
try {
129
- return ( await execa ( 'git' , [ 'check-ref-format' , `refs/tags/${ tagName } ` ] , { timeout } ) ) . code === 0 ;
126
+ return ( await execa ( 'git' , [ 'check-ref-format' , `refs/tags/${ tagName } ` ] ) ) . code === 0 ;
130
127
} catch ( err ) {
131
128
debug ( err ) ;
132
129
}
0 commit comments