Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
45eee4acdd | ||
|
|
2d3a5e53e9 | ||
|
|
4abda31f83 | ||
|
|
3602716c0b |
@@ -59,7 +59,7 @@ A `package.json` is required only for [local](../usage/installation.md#local-ins
|
||||
```json
|
||||
{
|
||||
"devDependencies": {
|
||||
"semantic-release": "^12.0.0"
|
||||
"semantic-release": "^15.0.0"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@@ -51,7 +51,7 @@ A `package.json` is required only for [local](../usage/installation.md#local-ins
|
||||
```json
|
||||
{
|
||||
"devDependencies": {
|
||||
"semantic-release": "^12.0.0"
|
||||
"semantic-release": "^15.0.0"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@@ -48,7 +48,7 @@ A `package.json` is required only for [local](../usage/installation.md#local-ins
|
||||
```json
|
||||
{
|
||||
"devDependencies": {
|
||||
"semantic-release": "^12.0.0"
|
||||
"semantic-release": "^15.0.0"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@@ -83,8 +83,8 @@ A `package.json` is required only for [local](../usage/installation.md#local-ins
|
||||
```json
|
||||
{
|
||||
"devDependencies": {
|
||||
"semantic-release": "^12.0.0",
|
||||
"travis-deploy-once": "^4.0.0"
|
||||
"semantic-release": "^15.0.0",
|
||||
"travis-deploy-once": "^5.0.0"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@@ -24,6 +24,6 @@ For other type of projects we recommend installing **semantic-release** directly
|
||||
$ npx semantic-release
|
||||
```
|
||||
|
||||
**Note:** For a global installation, it's recommended to specify the major **semantic-release** version to install (for example with with `npx semantic-release@12`, or `npm install -g semantic-release@12`). This way your build will not automatically use the next major **semantic-release** release that could possibly break your build. You will have to upgrade manually when a new major version is released.
|
||||
**Note:** For a global installation, it's recommended to specify the major **semantic-release** version to install (for example with with `npx semantic-release@15`, or `npm install -g semantic-release@15`). This way your build will not automatically use the next major **semantic-release** release that could possibly break your build. You will have to upgrade manually when a new major version is released.
|
||||
|
||||
**Note:** `npx` is a tool bundled with `npm@>=5.2.0`. It is used to conveniently install the semantic-release binary and to execute it. See [What is npx](../support/FAQ.md#what-is-npx) for more details.
|
||||
**Note:** `npx` is a tool bundled with `npm@>=5.2.0`. It is used to conveniently install the semantic-release binary and to execute it. See [What is npx](../support/FAQ.md#what-is-npx) for more details.
|
||||
|
||||
@@ -13,7 +13,7 @@ const getLastRelease = require('./lib/get-last-release');
|
||||
const {extractErrors} = require('./lib/utils');
|
||||
const getGitAuthUrl = require('./lib/get-git-auth-url');
|
||||
const logger = require('./lib/logger');
|
||||
const {unshallow, verifyAuth, isBranchUpToDate, gitHead: getGitHead, tag, push} = require('./lib/git');
|
||||
const {fetch, verifyAuth, isBranchUpToDate, gitHead: getGitHead, tag, push} = require('./lib/git');
|
||||
const getError = require('./lib/get-error');
|
||||
const {COMMIT_NAME, COMMIT_EMAIL} = require('./lib/definitions/constants');
|
||||
|
||||
@@ -75,8 +75,7 @@ async function run(options, plugins) {
|
||||
logger.log('Call plugin %s', 'verify-conditions');
|
||||
await plugins.verifyConditions({options, logger}, {settleAll: true});
|
||||
|
||||
// Unshallow the repo in order to get all the tags
|
||||
await unshallow(options.repositoryUrl);
|
||||
await fetch(options.repositoryUrl);
|
||||
|
||||
const lastRelease = await getLastRelease(options.tagFormat, logger);
|
||||
const commits = await getCommits(lastRelease.gitHead, options.branch, logger);
|
||||
|
||||
+8
-4
@@ -49,12 +49,16 @@ async function isRefInHistory(ref) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Unshallow the git repository (retriving every commits and tags).
|
||||
* Unshallow the git repository if necessary and fetch all the tags.
|
||||
*
|
||||
* @param {String} repositoryUrl The remote repository URL.
|
||||
*/
|
||||
async function unshallow(repositoryUrl) {
|
||||
await execa('git', ['fetch', '--unshallow', '--tags', repositoryUrl], {reject: false});
|
||||
async function fetch(repositoryUrl) {
|
||||
try {
|
||||
await execa('git', ['fetch', '--unshallow', '--tags', repositoryUrl]);
|
||||
} catch (err) {
|
||||
await execa('git', ['fetch', '--tags', repositoryUrl]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -160,7 +164,7 @@ module.exports = {
|
||||
gitTagHead,
|
||||
gitTags,
|
||||
isRefInHistory,
|
||||
unshallow,
|
||||
fetch,
|
||||
gitHead,
|
||||
repoUrl,
|
||||
isGitRepo,
|
||||
|
||||
+27
-9
@@ -3,7 +3,7 @@ import tempy from 'tempy';
|
||||
import {
|
||||
gitTagHead,
|
||||
isRefInHistory,
|
||||
unshallow,
|
||||
fetch,
|
||||
gitHead,
|
||||
repoUrl,
|
||||
tag,
|
||||
@@ -23,7 +23,8 @@ import {
|
||||
gitAddConfig,
|
||||
gitCommitTag,
|
||||
gitRemoteTagHead,
|
||||
push as pushUtil,
|
||||
gitPush,
|
||||
gitDetachedHead,
|
||||
} from './helpers/git-utils';
|
||||
|
||||
// Save the current working diretory
|
||||
@@ -52,7 +53,7 @@ test.serial('Throw error if the last commit sha cannot be found', async t => {
|
||||
await t.throws(gitHead(), Error);
|
||||
});
|
||||
|
||||
test.serial('Unshallow repository', async t => {
|
||||
test.serial('Unshallow and fetch repository', async t => {
|
||||
// Create a git repository, set the current working directory at the root of the repo
|
||||
const repo = await gitRepo();
|
||||
// Add commits to the master branch
|
||||
@@ -63,7 +64,7 @@ test.serial('Unshallow repository', async t => {
|
||||
// Verify the shallow clone contains only one commit
|
||||
t.is((await gitGetCommits()).length, 1);
|
||||
|
||||
await unshallow(repo);
|
||||
await fetch(repo);
|
||||
|
||||
// Verify the shallow clone contains all the commits
|
||||
t.is((await gitGetCommits()).length, 2);
|
||||
@@ -74,7 +75,24 @@ test.serial('Do not throw error when unshallow a complete repository', async t =
|
||||
const repo = await gitRepo();
|
||||
// Add commits to the master branch
|
||||
await gitCommits(['First']);
|
||||
await t.notThrows(unshallow(repo));
|
||||
await t.notThrows(fetch(repo));
|
||||
});
|
||||
|
||||
test.serial('Fetch all tags on a detached head repository', async t => {
|
||||
const repo = await gitRepo(true);
|
||||
|
||||
await gitCommits(['First']);
|
||||
await gitTagVersion('v1.0.0');
|
||||
await gitCommits(['Second']);
|
||||
await gitTagVersion('v1.0.1');
|
||||
const [commit] = await gitCommits(['Third']);
|
||||
await gitTagVersion('v1.1.0');
|
||||
await gitPush();
|
||||
await gitDetachedHead(repo, commit.hash);
|
||||
|
||||
await fetch(repo);
|
||||
|
||||
t.deepEqual((await gitTags()).sort(), ['v1.0.0', 'v1.0.1', 'v1.1.0'].sort());
|
||||
});
|
||||
|
||||
test.serial('Verify if the commit `sha` is in the direct history of the current branch', async t => {
|
||||
@@ -190,7 +208,7 @@ test.serial('Throws error if obtaining the tags fails', async t => {
|
||||
test.serial('Return "true" if repository is up to date', async t => {
|
||||
const repositoryUrl = await gitRepo(true);
|
||||
await gitCommits(['First']);
|
||||
await pushUtil();
|
||||
await gitPush();
|
||||
|
||||
t.true(await isBranchUpToDate(repositoryUrl, 'master'));
|
||||
});
|
||||
@@ -200,13 +218,13 @@ test.serial('Return falsy if repository is not up to date', async t => {
|
||||
const repoDir = process.cwd();
|
||||
await gitCommits(['First']);
|
||||
await gitCommits(['Second']);
|
||||
await pushUtil();
|
||||
await gitPush();
|
||||
|
||||
t.true(await isBranchUpToDate(repositoryUrl, 'master'));
|
||||
|
||||
await gitShallowClone(repositoryUrl);
|
||||
await gitCommits(['Third']);
|
||||
await pushUtil();
|
||||
await gitPush();
|
||||
process.chdir(repoDir);
|
||||
|
||||
t.falsy(await isBranchUpToDate(repositoryUrl, 'master'));
|
||||
@@ -215,7 +233,7 @@ test.serial('Return falsy if repository is not up to date', async t => {
|
||||
test.serial('Return "true" if local repository is ahead', async t => {
|
||||
const repositoryUrl = await gitRepo(true);
|
||||
await gitCommits(['First']);
|
||||
await pushUtil();
|
||||
await gitPush();
|
||||
await gitCommits(['Second']);
|
||||
|
||||
t.true(await isBranchUpToDate(repositoryUrl, 'master'));
|
||||
|
||||
@@ -151,7 +151,7 @@ export async function gitDetachedHead(repositoryUrl, head) {
|
||||
process.chdir(dir);
|
||||
await execa('git', ['init']);
|
||||
await execa('git', ['remote', 'add', 'origin', repositoryUrl]);
|
||||
await execa('git', ['fetch']);
|
||||
await execa('git', ['fetch', repositoryUrl]);
|
||||
await execa('git', ['checkout', head]);
|
||||
return dir;
|
||||
}
|
||||
@@ -209,6 +209,6 @@ export async function gitCommitTag(gitHead) {
|
||||
* @param {String} branch The branch to push.
|
||||
* @throws {Error} if the push failed.
|
||||
*/
|
||||
export async function push(repositoryUrl = 'origin', branch = 'master') {
|
||||
export async function gitPush(repositoryUrl = 'origin', branch = 'master') {
|
||||
await execa('git', ['push', '--tags', repositoryUrl, `HEAD:${branch}`]);
|
||||
}
|
||||
|
||||
+18
-18
@@ -13,7 +13,7 @@ import {
|
||||
gitCommits,
|
||||
gitTagVersion,
|
||||
gitRemoteTagHead,
|
||||
push,
|
||||
gitPush,
|
||||
gitShallowClone,
|
||||
} from './helpers/git-utils';
|
||||
|
||||
@@ -58,7 +58,7 @@ test.serial('Plugins are called with expected values', async t => {
|
||||
await gitTagVersion('v1.0.0');
|
||||
// Add new commits to the master branch
|
||||
commits = (await gitCommits(['Second'])).concat(commits);
|
||||
await push();
|
||||
await gitPush();
|
||||
|
||||
const lastRelease = {version: '1.0.0', gitHead: commits[commits.length - 1].hash, gitTag: 'v1.0.0'};
|
||||
const nextRelease = {type: 'major', version: '2.0.0', gitHead: await getGitHead(), gitTag: 'v2.0.0'};
|
||||
@@ -170,7 +170,7 @@ test.serial('Use custom tag format', async t => {
|
||||
await gitCommits(['First']);
|
||||
await gitTagVersion('test-1.0.0');
|
||||
await gitCommits(['Second']);
|
||||
await push();
|
||||
await gitPush();
|
||||
|
||||
const nextRelease = {type: 'major', version: '2.0.0', gitHead: await getGitHead(), gitTag: 'test-2.0.0'};
|
||||
const notes = 'Release notes';
|
||||
@@ -207,7 +207,7 @@ test.serial('Use new gitHead, and recreate release notes if a prepare plugin cre
|
||||
await gitTagVersion('v1.0.0');
|
||||
// Add new commits to the master branch
|
||||
commits = (await gitCommits(['Second'])).concat(commits);
|
||||
await push();
|
||||
await gitPush();
|
||||
|
||||
const nextRelease = {type: 'major', version: '2.0.0', gitHead: await getGitHead(), gitTag: 'v2.0.0'};
|
||||
const notes = 'Release notes';
|
||||
@@ -267,7 +267,7 @@ test.serial('Call all "success" plugins even if one errors out', async t => {
|
||||
await gitTagVersion('v1.0.0');
|
||||
// Add new commits to the master branch
|
||||
await gitCommits(['Second']);
|
||||
await push();
|
||||
await gitPush();
|
||||
|
||||
const nextRelease = {type: 'major', version: '2.0.0', gitHead: await getGitHead(), gitTag: 'v2.0.0'};
|
||||
const notes = 'Release notes';
|
||||
@@ -315,7 +315,7 @@ test.serial('Log all "verifyConditions" errors', async t => {
|
||||
const repositoryUrl = await gitRepo(true);
|
||||
// Add commits to the master branch
|
||||
await gitCommits(['First']);
|
||||
await push();
|
||||
await gitPush();
|
||||
|
||||
const error1 = new Error('error 1');
|
||||
const error2 = new SemanticReleaseError('error 2', 'ERR2');
|
||||
@@ -358,7 +358,7 @@ test.serial('Log all "verifyRelease" errors', async t => {
|
||||
await gitTagVersion('v1.0.0');
|
||||
// Add new commits to the master branch
|
||||
await gitCommits(['Second']);
|
||||
await push();
|
||||
await gitPush();
|
||||
|
||||
const error1 = new SemanticReleaseError('error 1', 'ERR1');
|
||||
const error2 = new SemanticReleaseError('error 2', 'ERR2');
|
||||
@@ -395,7 +395,7 @@ test.serial('Dry-run skips publish and success', async t => {
|
||||
await gitTagVersion('v1.0.0');
|
||||
// Add new commits to the master branch
|
||||
await gitCommits(['Second']);
|
||||
await push();
|
||||
await gitPush();
|
||||
|
||||
const nextRelease = {type: 'major', version: '2.0.0', gitHead: await getGitHead(), gitTag: 'v2.0.0'};
|
||||
const notes = 'Release notes';
|
||||
@@ -444,7 +444,7 @@ test.serial('Dry-run skips fail', async t => {
|
||||
await gitTagVersion('v1.0.0');
|
||||
// Add new commits to the master branch
|
||||
await gitCommits(['Second']);
|
||||
await push();
|
||||
await gitPush();
|
||||
|
||||
const error1 = new SemanticReleaseError('error 1', 'ERR1');
|
||||
const error2 = new SemanticReleaseError('error 2', 'ERR2');
|
||||
@@ -479,7 +479,7 @@ test.serial('Force a dry-run if not on a CI and "noCi" is not explicitly set', a
|
||||
await gitTagVersion('v1.0.0');
|
||||
// Add new commits to the master branch
|
||||
await gitCommits(['Second']);
|
||||
await push();
|
||||
await gitPush();
|
||||
|
||||
const nextRelease = {type: 'major', version: '2.0.0', gitHead: await getGitHead(), gitTag: 'v2.0.0'};
|
||||
const notes = 'Release notes';
|
||||
@@ -529,7 +529,7 @@ test.serial('Allow local releases with "noCi" option', async t => {
|
||||
await gitTagVersion('v1.0.0');
|
||||
// Add new commits to the master branch
|
||||
await gitCommits(['Second']);
|
||||
await push();
|
||||
await gitPush();
|
||||
|
||||
const nextRelease = {type: 'major', version: '2.0.0', gitHead: await getGitHead(), gitTag: 'v2.0.0'};
|
||||
const notes = 'Release notes';
|
||||
@@ -583,7 +583,7 @@ test.serial('Accept "undefined" value returned by the "generateNotes" plugins',
|
||||
await gitTagVersion('v1.0.0');
|
||||
// Add new commits to the master branch
|
||||
commits = (await gitCommits(['Second'])).concat(commits);
|
||||
await push();
|
||||
await gitPush();
|
||||
|
||||
const lastRelease = {version: '1.0.0', gitHead: commits[commits.length - 1].hash, gitTag: 'v1.0.0'};
|
||||
const nextRelease = {type: 'major', version: '2.0.0', gitHead: await getGitHead(), gitTag: 'v2.0.0'};
|
||||
@@ -648,10 +648,10 @@ test.serial('Returns falsy value if triggered on an outdated clone', async t =>
|
||||
// Add commits to the master branch
|
||||
await gitCommits(['First']);
|
||||
await gitCommits(['Second']);
|
||||
await push();
|
||||
await gitPush();
|
||||
await gitShallowClone(repositoryUrl);
|
||||
await gitCommits(['Third']);
|
||||
await push();
|
||||
await gitPush();
|
||||
process.chdir(repoDir);
|
||||
|
||||
const semanticRelease = proxyquire('..', {
|
||||
@@ -699,7 +699,7 @@ test.serial('Returns falsy value if there is no relevant changes', async t => {
|
||||
const repositoryUrl = await gitRepo(true);
|
||||
// Add commits to the master branch
|
||||
await gitCommits(['First']);
|
||||
await push();
|
||||
await gitPush();
|
||||
|
||||
const analyzeCommits = stub().resolves();
|
||||
const verifyRelease = stub().resolves();
|
||||
@@ -749,7 +749,7 @@ test.serial('Exclude commits with [skip release] or [release skip] from analysis
|
||||
'Test commit\n\n commit body\n[skip release]',
|
||||
'Test commit\n\n commit body\n[release skip]',
|
||||
]);
|
||||
await push();
|
||||
await gitPush();
|
||||
const analyzeCommits = stub().resolves();
|
||||
const config = {branch: 'master', repositoryUrl, globalOpt: 'global'};
|
||||
const options = {
|
||||
@@ -874,7 +874,7 @@ test.serial('Throw an Error if plugin returns an unexpected value', async t => {
|
||||
await gitTagVersion('v1.0.0');
|
||||
// Add new commits to the master branch
|
||||
await gitCommits(['Second']);
|
||||
await push();
|
||||
await gitPush();
|
||||
|
||||
const verifyConditions = stub().resolves();
|
||||
const analyzeCommits = stub().resolves('string');
|
||||
@@ -903,7 +903,7 @@ test.serial('Get all commits including the ones not in the shallow clone', async
|
||||
const repositoryUrl = await gitRepo(true);
|
||||
await gitTagVersion('v1.0.0');
|
||||
await gitCommits(['First', 'Second', 'Third']);
|
||||
await push(repositoryUrl, 'master');
|
||||
await gitPush(repositoryUrl, 'master');
|
||||
|
||||
await gitShallowClone(repositoryUrl);
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import test from 'ava';
|
||||
import {writeJson, readJson} from 'fs-extra';
|
||||
import {stub} from 'sinon';
|
||||
import execa from 'execa';
|
||||
import {gitHead as getGitHead, gitTagHead, gitRepo, gitCommits, gitRemoteTagHead, push} from './helpers/git-utils';
|
||||
import {gitHead as getGitHead, gitTagHead, gitRepo, gitCommits, gitRemoteTagHead, gitPush} from './helpers/git-utils';
|
||||
import gitbox from './helpers/gitbox';
|
||||
import mockServer from './helpers/mockserver';
|
||||
import npmRegistry from './helpers/npm-registry';
|
||||
@@ -609,7 +609,7 @@ test.serial('Exit with 1 if missing permission to push to the remote repository'
|
||||
/* Initial release */
|
||||
t.log('Commit a feature');
|
||||
await gitCommits(['feat: Initial commit']);
|
||||
await push();
|
||||
await gitPush();
|
||||
t.log('$ semantic-release');
|
||||
const {stdout, code} = await execa(
|
||||
cli,
|
||||
|
||||
Reference in New Issue
Block a user