Skip to content

Commit

Permalink
Merge branch 'master' into beta
Browse files Browse the repository at this point in the history
  • Loading branch information
pvdlg committed Oct 2, 2019
2 parents 768842e + 4b73226 commit 8c18ffa
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 35 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
@@ -1,8 +1,9 @@
language: node_js

node_js:
- 12
- 10
- 8
- 8.3

# Trigger a push build on release and greenkeeper branches + PRs build on every branches
# Avoid double build on PRs (See https://github.com/travis-ci/travis-ci/issues/1147)
Expand Down
6 changes: 3 additions & 3 deletions lib/git.js
Expand Up @@ -11,7 +11,7 @@ const debug = require('debug')('semantic-release:git');
*/
async function filterModifiedFiles(files, execaOpts) {
return files.length > 0
? (await execa.stdout('git', ['ls-files', '-m', '-o', ...files], execaOpts))
? (await execa('git', ['ls-files', '-m', '-o', ...files], execaOpts)).stdout
.split('\n')
.map(file => file.trim())
.filter(file => Boolean(file))
Expand Down Expand Up @@ -61,8 +61,8 @@ async function push(origin, branch, execaOpts) {
*
* @return {String} The sha of the head commit on the local repository
*/
function gitHead(execaOpts) {
return execa.stdout('git', ['rev-parse', 'HEAD'], execaOpts);
async function gitHead(execaOpts) {
return (await execa('git', ['rev-parse', 'HEAD'], execaOpts)).stdout;
}

module.exports = {filterModifiedFiles, add, gitHead, commit, push};
42 changes: 21 additions & 21 deletions package.json
Expand Up @@ -3,44 +3,45 @@
"description": "semantic-release plugin to commit release assets to the project's git repository",
"version": "0.0.0-development",
"author": "Pierre Vanduynslager (https://github.com/pvdlg)",
"ava": {
"files": [
"test/**/*.test.js"
],
"helpers": [
"test/helpers/**/*"
]
},
"bugs": {
"url": "https://github.com/semantic-release/git/issues"
},
"config": {
"commitizen": {
"path": "cz-conventional-changelog"
}
},
"contributors": [
"Stephan Bönnemann <stephan@boennemann.me> (http://boennemann.me)",
"Gregor Martynus (https://twitter.com/gr2m)"
],
"dependencies": {
"@semantic-release/error": "^2.1.0",
"aggregate-error": "^2.0.0",
"aggregate-error": "^3.0.0",
"debug": "^4.0.0",
"dir-glob": "^2.0.0",
"dir-glob": "^3.0.0",
"execa": "^1.0.0",
"fs-extra": "^7.0.0",
"globby": "^9.0.0",
"fs-extra": "^8.0.0",
"globby": "^10.0.0",
"lodash": "^4.17.4",
"micromatch": "^3.1.4",
"p-reduce": "^1.0.0"
"micromatch": "^4.0.0",
"p-reduce": "^2.0.0"
},
"devDependencies": {
"ava": "^1.0.1",
"clear-module": "^3.0.0",
"ava": "^2.0.0",
"clear-module": "^4.0.0",
"codecov": "^3.0.0",
"commitizen": "^3.0.0",
"cz-conventional-changelog": "^2.0.0",
"file-url": "^2.0.2",
"get-stream": "^4.0.0",
"file-url": "^3.0.0",
"get-stream": "^5.0.0",
"git-log-parser": "^1.2.0",
"nyc": "^13.1.0",
"nyc": "^14.0.0",
"semantic-release": "^16.0.0-beta",
"sinon": "^7.1.1",
"tempy": "^0.2.1",
"xo": "^0.24.0"
"tempy": "^0.3.0",
"xo": "^0.25.2"
},
"engines": {
"node": ">=8.3"
Expand Down Expand Up @@ -89,7 +90,6 @@
"url": "https://github.com/semantic-release/git.git"
},
"scripts": {
"cm": "git-cz",
"codecov": "codecov -f coverage/coverage-final.json",
"lint": "xo",
"pretest": "npm run lint",
Expand Down
2 changes: 1 addition & 1 deletion test/git.test.js
Expand Up @@ -94,5 +94,5 @@ test('Push commit to remote repository', async t => {

await push(repositoryUrl, 'master', {cwd});

t.is(await gitRemoteHead(repositoryUrl), hash, {cwd});
t.is(await gitRemoteHead(repositoryUrl, {cwd}), hash);
});
20 changes: 11 additions & 9 deletions test/helpers/git-utils.js
Expand Up @@ -60,8 +60,10 @@ export async function initBareRepo(repositoryUrl, branch = 'master') {
* @returns {Array<Commit>} The created commits, in reverse order (to match `git log` order).
*/
export async function gitCommits(messages, execaOpts) {
await pReduce(messages, (_, message) =>
execa.stdout('git', ['commit', '-m', message, '--allow-empty', '--no-gpg-sign'], execaOpts)
await pReduce(
messages,
async (_, message) =>
(await execa('git', ['commit', '-m', message, '--allow-empty', '--no-gpg-sign'], execaOpts)).stdout
);
return (await gitGetCommits(undefined, execaOpts)).slice(0, messages.length);
}
Expand Down Expand Up @@ -89,10 +91,10 @@ export async function gitGetCommits(from, execaOpts) {
* Checkout a branch on the current git repository.
*
* @param {String} branch Branch name.
* @param {Boolean} create `true` to create the branch, `false` to checkout an existing branch.
* @param {Boolean} create to create the branch, `false` to checkout an existing branch.
* @param {Object} [execaOpts] Options to pass to `execa`.
*/
export async function gitCheckout(branch, create = true, execaOpts) {
export async function gitCheckout(branch, create, execaOpts) {
await execa('git', create ? ['checkout', '-b', branch] : ['checkout', branch], execaOpts);
}

Expand Down Expand Up @@ -151,7 +153,7 @@ export async function gitDetachedHead(repositoryUrl, head) {
* @return {String} The HEAD sha of the remote repository.
*/
export async function gitRemoteHead(repositoryUrl, execaOpts) {
return (await execa.stdout('git', ['ls-remote', repositoryUrl, 'HEAD'], execaOpts))
return (await execa('git', ['ls-remote', repositoryUrl, 'HEAD'], execaOpts)).stdout
.split('\n')
.filter(head => Boolean(head))
.map(head => head.match(/^(\S+)/)[1])[0];
Expand All @@ -165,7 +167,7 @@ export async function gitRemoteHead(repositoryUrl, execaOpts) {
* @return {Array<String>} Array of staged files path.
*/
export async function gitStaged(execaOpts) {
return (await execa.stdout('git', ['status', '--porcelain'], execaOpts))
return (await execa('git', ['status', '--porcelain'], execaOpts)).stdout
.split('\n')
.filter(status => status.startsWith('A '))
.map(status => status.match(/^A\s+(.+)$/)[1]);
Expand All @@ -174,13 +176,13 @@ export async function gitStaged(execaOpts) {
/**
* Get the list of files included in a commit.
*
* @param {String} [ref='HEAD'] The git reference for which to retrieve the files.
* @param {String} ref The git reference for which to retrieve the files.
* @param {Object} [execaOpts] Options to pass to `execa`.
*
* @return {Array<String>} The list of files path included in the commit.
*/
export async function gitCommitedFiles(ref = 'HEAD', execaOpts) {
return (await execa.stdout('git', ['diff-tree', '-r', '--name-only', '--no-commit-id', '-r', ref], execaOpts))
export async function gitCommitedFiles(ref, execaOpts) {
return (await execa('git', ['diff-tree', '-r', '--name-only', '--no-commit-id', '-r', ref], execaOpts)).stdout
.split('\n')
.filter(file => Boolean(file));
}

0 comments on commit 8c18ffa

Please sign in to comment.