fix: remove execa
timeout
This commit is contained in:
parent
dff0a34ab2
commit
3c46455929
25
lib/git.js
25
lib/git.js
@ -1,8 +1,5 @@
|
|||||||
const execa = require('execa');
|
const execa = require('execa');
|
||||||
const debug = require('debug')('semantic-release:git');
|
const debug = require('debug')('semantic-release:git');
|
||||||
const envCi = require('env-ci');
|
|
||||||
|
|
||||||
const timeout = envCi().isCi ? 10000 : 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the commit sha for a given tag.
|
* Get the commit sha for a given tag.
|
||||||
@ -13,7 +10,7 @@ const timeout = envCi().isCi ? 10000 : 0;
|
|||||||
*/
|
*/
|
||||||
async function gitTagHead(tagName) {
|
async function gitTagHead(tagName) {
|
||||||
try {
|
try {
|
||||||
return await execa.stdout('git', ['rev-list', '-1', tagName], {timeout});
|
return await execa.stdout('git', ['rev-list', '-1', tagName]);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
debug(err);
|
debug(err);
|
||||||
}
|
}
|
||||||
@ -24,7 +21,7 @@ async function gitTagHead(tagName) {
|
|||||||
* @throws {Error} If the `git` command fails.
|
* @throws {Error} If the `git` command fails.
|
||||||
*/
|
*/
|
||||||
async function gitTags() {
|
async function gitTags() {
|
||||||
return (await execa.stdout('git', ['tag'], {timeout}))
|
return (await execa.stdout('git', ['tag']))
|
||||||
.split('\n')
|
.split('\n')
|
||||||
.map(tag => tag.trim())
|
.map(tag => tag.trim())
|
||||||
.filter(tag => Boolean(tag));
|
.filter(tag => Boolean(tag));
|
||||||
@ -39,7 +36,7 @@ async function gitTags() {
|
|||||||
*/
|
*/
|
||||||
async function isRefInHistory(ref) {
|
async function isRefInHistory(ref) {
|
||||||
try {
|
try {
|
||||||
return (await execa('git', ['merge-base', '--is-ancestor', ref, 'HEAD'], {timeout})).code === 0;
|
return (await execa('git', ['merge-base', '--is-ancestor', ref, 'HEAD'])).code === 0;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
debug(err);
|
debug(err);
|
||||||
}
|
}
|
||||||
@ -49,14 +46,14 @@ async function isRefInHistory(ref) {
|
|||||||
* Unshallow the git repository (retriving every commits and tags).
|
* Unshallow the git repository (retriving every commits and tags).
|
||||||
*/
|
*/
|
||||||
async function unshallow() {
|
async function unshallow() {
|
||||||
await execa('git', ['fetch', '--unshallow', '--tags'], {reject: false, timeout});
|
await execa('git', ['fetch', '--unshallow', '--tags'], {reject: false});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {string} the sha of the HEAD commit.
|
* @return {string} the sha of the HEAD commit.
|
||||||
*/
|
*/
|
||||||
async function gitHead() {
|
async function gitHead() {
|
||||||
return execa.stdout('git', ['rev-parse', 'HEAD'], {timeout});
|
return execa.stdout('git', ['rev-parse', 'HEAD']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,7 +61,7 @@ async function gitHead() {
|
|||||||
*/
|
*/
|
||||||
async function repoUrl() {
|
async function repoUrl() {
|
||||||
try {
|
try {
|
||||||
return await execa.stdout('git', ['remote', 'get-url', 'origin'], {timeout});
|
return await execa.stdout('git', ['remote', 'get-url', 'origin']);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
debug(err);
|
debug(err);
|
||||||
}
|
}
|
||||||
@ -75,7 +72,7 @@ async function repoUrl() {
|
|||||||
*/
|
*/
|
||||||
async function isGitRepo() {
|
async function isGitRepo() {
|
||||||
try {
|
try {
|
||||||
return (await execa('git', ['rev-parse', '--git-dir'], {timeout})).code === 0;
|
return (await execa('git', ['rev-parse', '--git-dir'])).code === 0;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
debug(err);
|
debug(err);
|
||||||
}
|
}
|
||||||
@ -91,7 +88,7 @@ async function isGitRepo() {
|
|||||||
*/
|
*/
|
||||||
async function verifyAuth(origin, branch) {
|
async function verifyAuth(origin, branch) {
|
||||||
try {
|
try {
|
||||||
return (await execa('git', ['push', '--dry-run', origin, `HEAD:${branch}`], {timeout})).code === 0;
|
return (await execa('git', ['push', '--dry-run', origin, `HEAD:${branch}`])).code === 0;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
debug(err);
|
debug(err);
|
||||||
}
|
}
|
||||||
@ -104,7 +101,7 @@ async function verifyAuth(origin, branch) {
|
|||||||
* @throws {Error} if the tag creation failed.
|
* @throws {Error} if the tag creation failed.
|
||||||
*/
|
*/
|
||||||
async function tag(tagName) {
|
async function tag(tagName) {
|
||||||
await execa('git', ['tag', tagName], {timeout});
|
await execa('git', ['tag', tagName]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -115,7 +112,7 @@ async function tag(tagName) {
|
|||||||
* @throws {Error} if the push failed.
|
* @throws {Error} if the push failed.
|
||||||
*/
|
*/
|
||||||
async function push(origin, branch) {
|
async function push(origin, branch) {
|
||||||
await execa('git', ['push', '--tags', origin, `HEAD:${branch}`], {timeout});
|
await execa('git', ['push', '--tags', origin, `HEAD:${branch}`]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -126,7 +123,7 @@ async function push(origin, branch) {
|
|||||||
*/
|
*/
|
||||||
async function verifyTagName(tagName) {
|
async function verifyTagName(tagName) {
|
||||||
try {
|
try {
|
||||||
return (await execa('git', ['check-ref-format', `refs/tags/${tagName}`], {timeout})).code === 0;
|
return (await execa('git', ['check-ref-format', `refs/tags/${tagName}`])).code === 0;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
debug(err);
|
debug(err);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user