@@ -9,7 +9,11 @@ const debug = require('debug')('semantic-release:get-version-head');
9
9
* @return {string } The commit sha of the tag in parameter or `null`.
10
10
*/
11
11
async function gitTagHead ( tagName ) {
12
- return execa . stdout ( 'git' , [ 'rev-list' , '-1' , tagName ] , { reject : false } ) ;
12
+ try {
13
+ return await execa . stdout ( 'git' , [ 'rev-list' , '-1' , tagName ] ) ;
14
+ } catch ( err ) {
15
+ debug ( err ) ;
16
+ }
13
17
}
14
18
15
19
/**
@@ -28,10 +32,14 @@ async function gitTags() {
28
32
*
29
33
* @param {string } ref The reference to look for.
30
34
*
31
- * @return {boolean } `true` if the reference is in the history of the current branch, `false` otherwise.
35
+ * @return {boolean } `true` if the reference is in the history of the current branch, falsy otherwise.
32
36
*/
33
37
async function isRefInHistory ( ref ) {
34
- return ( await execa ( 'git' , [ 'merge-base' , '--is-ancestor' , ref , 'HEAD' ] , { reject : false } ) ) . code === 0 ;
38
+ try {
39
+ return ( await execa ( 'git' , [ 'merge-base' , '--is-ancestor' , ref , 'HEAD' ] ) ) . code === 0 ;
40
+ } catch ( err ) {
41
+ debug ( err ) ;
42
+ }
35
43
}
36
44
37
45
/**
@@ -52,14 +60,22 @@ async function gitHead() {
52
60
* @return {string } The value of the remote git URL.
53
61
*/
54
62
async function repoUrl ( ) {
55
- return execa . stdout ( 'git' , [ 'remote' , 'get-url' , 'origin' ] , { reject : false } ) ;
63
+ try {
64
+ return await execa . stdout ( 'git' , [ 'remote' , 'get-url' , 'origin' ] ) ;
65
+ } catch ( err ) {
66
+ debug ( err ) ;
67
+ }
56
68
}
57
69
58
70
/**
59
- * @return {Boolean } `true` if the current working directory is in a git repository, `false` otherwise.
71
+ * @return {Boolean } `true` if the current working directory is in a git repository, falsy otherwise.
60
72
*/
61
73
async function isGitRepo ( ) {
62
- return ( await execa ( 'git' , [ 'rev-parse' , '--git-dir' ] , { reject : false } ) ) . code === 0 ;
74
+ try {
75
+ return ( await execa ( 'git' , [ 'rev-parse' , '--git-dir' ] ) ) . code === 0 ;
76
+ } catch ( err ) {
77
+ debug ( err ) ;
78
+ }
63
79
}
64
80
65
81
/**
@@ -68,10 +84,14 @@ async function isGitRepo() {
68
84
* @param {String } origin The remote repository URL.
69
85
* @param {String } branch The repositoru branch for which to verify write access.
70
86
*
71
- * @return {Boolean } `true` is authorized to push, `false` otherwise.
87
+ * @return {Boolean } `true` is authorized to push, falsy otherwise.
72
88
*/
73
89
async function verifyAuth ( origin , branch ) {
74
- return ( await execa ( 'git' , [ 'push' , '--dry-run' , origin , `HEAD:${ branch } ` ] , { reject : false } ) ) . code === 0 ;
90
+ try {
91
+ return ( await execa ( 'git' , [ 'push' , '--dry-run' , origin , `HEAD:${ branch } ` ] ) ) . code === 0 ;
92
+ } catch ( err ) {
93
+ debug ( err ) ;
94
+ }
75
95
}
76
96
77
97
/**
@@ -117,10 +137,14 @@ async function deleteTag(origin, tagName) {
117
137
*
118
138
* @method verifyTagName
119
139
* @param {string } tagName the tag name to verify.
120
- * @return {boolean } `true` if valid, `false` otherwise.
140
+ * @return {boolean } `true` if valid, falsy otherwise.
121
141
*/
122
142
async function verifyTagName ( tagName ) {
123
- return ( await execa ( 'git' , [ 'check-ref-format' , `refs/tags/${ tagName } ` ] , { reject : false } ) ) . code === 0 ;
143
+ try {
144
+ return ( await execa ( 'git' , [ 'check-ref-format' , `refs/tags/${ tagName } ` ] ) ) . code === 0 ;
145
+ } catch ( err ) {
146
+ debug ( err ) ;
147
+ }
124
148
}
125
149
126
150
module . exports = {
0 commit comments