fix: fetch all release branches on CI
This commit is contained in:
@@ -22,7 +22,7 @@ test('Enforce ranges with branching release workflow', async t => {
|
||||
{name: 'beta', prerelease: true, tags: []},
|
||||
{name: 'alpha', prerelease: true, tags: []},
|
||||
];
|
||||
const getBranches = proxyquire('../../lib/branches', {'./get-tags': () => branches});
|
||||
const getBranches = proxyquire('../../lib/branches', {'./get-tags': () => branches, './expand': () => []});
|
||||
|
||||
let result = (await getBranches({options: {branches}})).map(({name, range}) => ({name, range}));
|
||||
t.is(getBranch(result, '1.0.x').range, '>=1.0.0 <1.0.0', 'Cannot release on 1.0.x before a releasing on master');
|
||||
@@ -145,7 +145,7 @@ test('Throw SemanticReleaseError for invalid configurations', async t => {
|
||||
{name: 'alpha', prerelease: 'alpha', tags: []},
|
||||
{name: 'preview', prerelease: 'alpha', tags: []},
|
||||
];
|
||||
const getBranches = proxyquire('../../lib/branches', {'./get-tags': () => branches});
|
||||
const getBranches = proxyquire('../../lib/branches', {'./get-tags': () => branches, './expand': () => []});
|
||||
const errors = [...(await t.throws(getBranches({options: {branches}})))];
|
||||
|
||||
t.is(errors[0].name, 'SemanticReleaseError');
|
||||
@@ -172,7 +172,7 @@ test('Throw SemanticReleaseError for invalid configurations', async t => {
|
||||
|
||||
test('Throw a SemanticReleaseError if there is duplicate branches', async t => {
|
||||
const branches = [{name: 'master', tags: []}, {name: 'master', tags: []}];
|
||||
const getBranches = proxyquire('../../lib/branches', {'./get-tags': () => branches});
|
||||
const getBranches = proxyquire('../../lib/branches', {'./get-tags': () => branches, './expand': () => []});
|
||||
|
||||
const errors = [...(await t.throws(getBranches({options: {branches}})))];
|
||||
|
||||
@@ -184,7 +184,7 @@ test('Throw a SemanticReleaseError if there is duplicate branches', async t => {
|
||||
|
||||
test('Throw a SemanticReleaseError for each invalid branch name', async t => {
|
||||
const branches = [{name: '~master', tags: []}, {name: '^master', tags: []}];
|
||||
const getBranches = proxyquire('../../lib/branches', {'./get-tags': () => branches});
|
||||
const getBranches = proxyquire('../../lib/branches', {'./get-tags': () => branches, './expand': () => []});
|
||||
|
||||
const errors = [...(await t.throws(getBranches({options: {branches}})))];
|
||||
|
||||
|
||||
@@ -1,24 +1,32 @@
|
||||
import test from 'ava';
|
||||
import expand from '../../lib/branches/expand';
|
||||
import {gitRepo, gitCommits, gitCheckout} from '../helpers/git-utils';
|
||||
import {gitRepo, gitCommits, gitCheckout, gitPush} from '../helpers/git-utils';
|
||||
|
||||
test('Expand branches defined with globs', async t => {
|
||||
const {cwd} = await gitRepo();
|
||||
const {cwd, repositoryUrl} = await gitRepo(true);
|
||||
await gitCommits(['First'], {cwd});
|
||||
await gitPush(repositoryUrl, 'master', {cwd});
|
||||
await gitCheckout('1.1.x', true, {cwd});
|
||||
await gitCommits(['Second'], {cwd});
|
||||
await gitPush(repositoryUrl, '1.1.x', {cwd});
|
||||
await gitCheckout('1.x.x', true, {cwd});
|
||||
await gitCommits(['Third'], {cwd});
|
||||
await gitPush(repositoryUrl, '1.x.x', {cwd});
|
||||
await gitCheckout('2.x', true, {cwd});
|
||||
await gitCommits(['Fourth'], {cwd});
|
||||
await gitPush(repositoryUrl, '2.x', {cwd});
|
||||
await gitCheckout('next', true, {cwd});
|
||||
await gitCommits(['Fifth'], {cwd});
|
||||
await gitPush(repositoryUrl, 'next', {cwd});
|
||||
await gitCheckout('pre/foo', true, {cwd});
|
||||
await gitCommits(['Sixth'], {cwd});
|
||||
await gitPush(repositoryUrl, 'pre/foo', {cwd});
|
||||
await gitCheckout('pre/bar', true, {cwd});
|
||||
await gitCommits(['Seventh'], {cwd});
|
||||
await gitPush(repositoryUrl, 'pre/bar', {cwd});
|
||||
await gitCheckout('beta', true, {cwd});
|
||||
await gitCommits(['Eighth'], {cwd});
|
||||
await gitPush(repositoryUrl, 'beta', {cwd});
|
||||
|
||||
const branches = [
|
||||
// Should match all maintenance type branches
|
||||
|
||||
+14
-6
@@ -58,7 +58,7 @@ test('Unshallow and fetch repository', async t => {
|
||||
// Verify the shallow clone contains only one commit
|
||||
t.is((await gitGetCommits(undefined, {cwd})).length, 1);
|
||||
|
||||
await fetch({cwd});
|
||||
await fetch('master', {cwd});
|
||||
|
||||
// Verify the shallow clone contains all the commits
|
||||
t.is((await gitGetCommits(undefined, {cwd})).length, 2);
|
||||
@@ -66,10 +66,15 @@ test('Unshallow and fetch repository', async t => {
|
||||
|
||||
test('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
|
||||
const {cwd} = await gitRepo(true);
|
||||
// Add commits to the master branch
|
||||
const {cwd, repositoryUrl} = await gitRepo(true);
|
||||
await gitCommits(['First'], {cwd});
|
||||
await t.notThrows(fetch({cwd}));
|
||||
await gitPush(repositoryUrl, 'master', {cwd});
|
||||
await gitCheckout('second-branch', true, {cwd});
|
||||
await gitCommits(['Second'], {cwd});
|
||||
await gitPush(repositoryUrl, 'second-branch', {cwd});
|
||||
|
||||
await t.notThrows(fetch('master', {cwd}));
|
||||
await t.notThrows(fetch('second-branch', {cwd}));
|
||||
});
|
||||
|
||||
test('Fetch all tags on a detached head repository', async t => {
|
||||
@@ -84,7 +89,7 @@ test('Fetch all tags on a detached head repository', async t => {
|
||||
await gitPush(repositoryUrl, 'master', {cwd});
|
||||
cwd = await gitDetachedHead(repositoryUrl, commit.hash);
|
||||
|
||||
await fetch({cwd});
|
||||
await fetch('master', {cwd});
|
||||
|
||||
t.deepEqual((await getTags({cwd})).sort(), ['v1.0.0', 'v1.0.1', 'v1.1.0'].sort());
|
||||
});
|
||||
@@ -122,12 +127,15 @@ test('Verify if a branch exists', async t => {
|
||||
});
|
||||
|
||||
test('Get all branches', async t => {
|
||||
const {cwd} = await gitRepo();
|
||||
const {cwd, repositoryUrl} = await gitRepo(true);
|
||||
await gitCommits(['First'], {cwd});
|
||||
await gitPush(repositoryUrl, 'master', {cwd});
|
||||
await gitCheckout('second-branch', true, {cwd});
|
||||
await gitCommits(['Second'], {cwd});
|
||||
await gitPush(repositoryUrl, 'second-branch', {cwd});
|
||||
await gitCheckout('third-branch', true, {cwd});
|
||||
await gitCommits(['Third'], {cwd});
|
||||
await gitPush(repositoryUrl, 'third-branch', {cwd});
|
||||
|
||||
t.deepEqual((await getBranches({cwd})).sort(), ['master', 'second-branch', 'third-branch'].sort());
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user