Compare commits

...
3 Commits
4 changed files with 18 additions and 10 deletions
+1 -1
View File
@@ -105,7 +105,7 @@ Default: `false`
CLI argument: `--debug`
Output debugging information. It can also be enabled by set the `DEBUG` environment variable to `semantic-release`.
Output debugging information. It can also be enabled by set the `DEBUG` environment variable to `semantic-release:*`.
### verifyConditions
+10 -2
View File
@@ -2,6 +2,7 @@ const {castArray, pickBy, isUndefined, isNull, isString, isPlainObject} = requir
const readPkgUp = require('read-pkg-up');
const cosmiconfig = require('cosmiconfig');
const resolveFrom = require('resolve-from');
const gitUrlParse = require('git-url-parse');
const debug = require('debug')('semantic-release:config');
const {repoUrl, verifyAuth} = require('./git');
const PLUGINS_DEFINITIONS = require('./definitions/plugins');
@@ -61,6 +62,13 @@ module.exports = async (opts, logger) => {
};
async function pkgRepoUrl() {
const {pkg} = await readPkgUp();
return pkg && pkg.repository ? pkg.repository.url : undefined;
const {pkg} = await readPkgUp({normalize: false});
const repositoryUrl = pkg && (isPlainObject(pkg.repository) ? pkg.repository.url : pkg.repository);
if (repositoryUrl) {
const {protocols} = gitUrlParse(repositoryUrl);
return `${gitUrlParse(repositoryUrl).toString(
protocols.includes('https') ? 'https' : protocols.includes('http') ? 'http' : undefined
)}${protocols.includes('https') || protocols.includes('http') ? '.git' : ''}`;
}
}
+1 -1
View File
@@ -1,5 +1,5 @@
const execa = require('execa');
const debug = require('debug')('semantic-release:get-version-head');
const debug = require('debug')('semantic-release:git');
/**
* Get the commit sha for a given tag.
+6 -6
View File
@@ -604,17 +604,17 @@ test.serial('Exit with 1 if missing permission to push to the remote repository'
// Create a git repository, set the current working directory at the root of the repo
t.log('Create git repository');
await gitbox.createRepo(packageName);
await writeJson('./package.json', {
name: packageName,
version: '0.0.0-dev',
repository: {url: 'http://user:wrong_pass@localhost:2080/git/unauthorized.git'},
});
await writeJson('./package.json', {name: packageName, version: '0.0.0-dev'});
/* Initial release */
t.log('Commit a feature');
await gitCommits(['feat: Initial commit']);
t.log('$ semantic-release');
const {stdout, code} = await execa(cli, [], {env: {...env, ...{GH_TOKEN: 'user:wrong_pass'}}, reject: false});
const {stdout, code} = await execa(
cli,
['--repository-url', 'http://user:wrong_pass@localhost:2080/git/unauthorized.git'],
{env: {...env, ...{GH_TOKEN: 'user:wrong_pass'}}, reject: false}
);
// Verify the type and message are logged
t.regex(stdout, /EGITNOPERMISSION/);
t.is(code, 1);