From 2d3a5e53e9aafd62a385492ad45cfc16b0ff239d Mon Sep 17 00:00:00 2001 From: Pierre Vanduynslager Date: Mon, 2 Jul 2018 18:24:28 -0400 Subject: [PATCH] test: harmonize `git-utils` functions name --- test/git.test.js | 10 +++++----- test/helpers/git-utils.js | 2 +- test/index.test.js | 36 ++++++++++++++++++------------------ test/integration.test.js | 4 ++-- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/test/git.test.js b/test/git.test.js index 95e1516f..1e7988d8 100644 --- a/test/git.test.js +++ b/test/git.test.js @@ -23,7 +23,7 @@ import { gitAddConfig, gitCommitTag, gitRemoteTagHead, - push as pushUtil, + gitPush, } from './helpers/git-utils'; // Save the current working diretory @@ -190,7 +190,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 +200,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 +215,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')); diff --git a/test/helpers/git-utils.js b/test/helpers/git-utils.js index fa28481b..05c17cc5 100644 --- a/test/helpers/git-utils.js +++ b/test/helpers/git-utils.js @@ -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}`]); } diff --git a/test/index.test.js b/test/index.test.js index fd431f44..e24d2247 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -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); diff --git a/test/integration.test.js b/test/integration.test.js index fc35d3c7..3afe241a 100644 --- a/test/integration.test.js +++ b/test/integration.test.js @@ -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,