- Add a new plugin type: `publish` - Add support for multi-plugin. A plugin module can now return an object with a property for each plugin type - Uses by default [npm](https://github.com/semantic-release/npm) and [github](https://github.com/semantic-release/github) in addition of Travis for the verify condition plugin - Uses by default [npm](https://github.com/semantic-release/npm) and [github](https://github.com/semantic-release/github) for the publish plugin - `gitTag` if one can be found is passed to `generateNotes` for both `lastRelease` and `nextRelease` - `semantic-release` now verifies the plugin configuration (in the `release` property of `package.json`) and throws an error if it's invalid - `semantic-release` now verifies each plugin output and will throw an error if a plugin returns an unexpected value. BREAKING CHANGE: `githubToken`, `githubUrl` and `githubApiPathPrefix` have to be set at the [github](https://github.com/semantic-release/github) plugin level. They can be set via `GH_TOKEN`, `GH_URL` and `GH_PREFIX` environment variables. BREAKING CHANGE: the `npm` parameter is not passed to any plugin anymore. Each plugin have to read `.npmrc` if they needs to (with https://github.com/kevva/npm-conf for example).
96 lines
3.4 KiB
JavaScript
96 lines
3.4 KiB
JavaScript
import test from 'ava';
|
|
import {gitRepo, gitCommits, gitCheckout, gitTagVersion, gitShallowClone, gitLog} from './helpers/git-utils';
|
|
import {gitTagHead, gitCommitTag, isCommitInHistory, unshallow, gitHead} from '../lib/git';
|
|
|
|
test.beforeEach(t => {
|
|
// Save the current working diretory
|
|
t.context.cwd = process.cwd();
|
|
});
|
|
|
|
test.afterEach.always(t => {
|
|
// Restore the current working directory
|
|
process.chdir(t.context.cwd);
|
|
});
|
|
|
|
test.serial('Get the last commit sha', async t => {
|
|
// Create a git repository, set the current working directory at the root of the repo
|
|
await gitRepo();
|
|
// Add commits to the master branch
|
|
const commits = await gitCommits(['First']);
|
|
|
|
const result = await gitHead();
|
|
|
|
t.is(result.substring(0, 7), commits[0].hash);
|
|
});
|
|
|
|
test.serial('Throw error if the last commit sha cannot be found', async t => {
|
|
// Create a git repository, set the current working directory at the root of the repo
|
|
await gitRepo();
|
|
|
|
await t.throws(gitHead());
|
|
});
|
|
|
|
test.serial('Unshallow 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
|
|
await gitCommits(['First', 'Second']);
|
|
// Create a shallow clone with only 1 commit
|
|
await gitShallowClone(repo);
|
|
|
|
// Verify the shallow clone contains only one commit
|
|
t.is((await gitLog()).length, 1);
|
|
|
|
await unshallow();
|
|
|
|
// Verify the shallow clone contains all the commits
|
|
t.is((await gitLog()).length, 2);
|
|
});
|
|
|
|
test.serial('Do not throw error when unshallow a complete repository', async t => {
|
|
// Create a git repository, set the current working directory at the root of the repo
|
|
await gitRepo();
|
|
// Add commits to the master branch
|
|
await gitCommits(['First']);
|
|
await t.notThrows(unshallow());
|
|
});
|
|
|
|
test.serial('Verify if the commit `sha` is in the direct history of the current branch', async t => {
|
|
// Create a git repository, set the current working directory at the root of the repo
|
|
await gitRepo();
|
|
// Add commits to the master branch
|
|
const commits = await gitCommits(['First']);
|
|
// Create the new branch 'other-branch' from master
|
|
await gitCheckout('other-branch');
|
|
// Add commits to the 'other-branch' branch
|
|
const otherCommits = await gitCommits(['Second']);
|
|
await gitCheckout('master', false);
|
|
|
|
t.true(await isCommitInHistory(commits[0].hash));
|
|
t.false(await isCommitInHistory(otherCommits[0].hash));
|
|
});
|
|
|
|
test.serial('Get the tag associated with a commit sha or "null" if the commit does not exists', async t => {
|
|
// Create a git repository, set the current working directory at the root of the repo
|
|
await gitRepo();
|
|
// Add commits to the master branch
|
|
let commits = await gitCommits(['First']);
|
|
// Create the tag corresponding to version 1.0.0
|
|
await gitTagVersion('v1.0.0');
|
|
|
|
t.is(await gitCommitTag(commits[0].hash), 'v1.0.0');
|
|
t.falsy(await gitCommitTag('missing_sha'));
|
|
});
|
|
|
|
test.serial('Get the commit sha for a given tag or "null" if the tag does not exists', async t => {
|
|
// Create a git repository, set the current working directory at the root of the repo
|
|
await gitRepo();
|
|
// Add commits to the master branch
|
|
let commits = await gitCommits(['First']);
|
|
// Create the tag corresponding to version 1.0.0
|
|
await gitTagVersion('v1.0.0');
|
|
|
|
t.is((await gitTagHead('v1.0.0')).substring(0, 7), commits[0].hash);
|
|
t.falsy(await gitTagHead('missing_tag'));
|
|
});
|