Skip to content

Commit

Permalink
Merge branch 'updating'
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalrymple committed Apr 29, 2018
2 parents ef64f30 + 3cebb92 commit a2fb9be
Show file tree
Hide file tree
Showing 9 changed files with 167 additions and 57 deletions.
17 changes: 17 additions & 0 deletions .codeclimate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
engines:
eslint:
enabled: true
duplication:
enabled: true
config:
languages:
javascript:
mass_threshold: 65
shellcheck:
enabled: true
checks:
method-count:
enabled: false
ratings:
paths:
- "**.js"
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ node_js:
- "7.6"
- "7"
- "8"
- "9"
before_install:
- sudo apt-get update
- sudo apt-get install python2.7
Expand Down
23 changes: 23 additions & 0 deletions LICENCE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
The MIT License
===============

Copyright (c)
**2017 Justin Dalrymple**

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[![Coverage Status](https://coveralls.io/repos/github/jdalrymple/node-hg-plus/badge.svg?branch=master)](https://coveralls.io/github/jdalrymple/node-hg-plus?branch=master) [![Build Status](https://travis-ci.org/jdalrymple/node-hg-plus.svg?branch=master)](https://travis-ci.org/jdalrymple/node-hg-plus) [![Dependency Status](https://david-dm.org/jdalrymple/node-hg-plus/status.svg)](https://david-dm.org/jdalrymple/node-test#info=dependencies) [![devDependency Status](https://david-dm.org/jdalrymple/node-hg-plus/dev-status.svg)](https://david-dm.org/jdalrymple/node-test#info=devDependencies)
[![Coverage Status](https://coveralls.io/repos/github/jdalrymple/node-hg-plus/badge.svg?branch=master)](https://coveralls.io/github/jdalrymple/node-hg-plus?branch=master) [![Build Status](https://travis-ci.org/jdalrymple/node-hg-plus.svg?branch=master)](https://travis-ci.org/jdalrymple/node-hg-plus) [![Dependency Status](https://david-dm.org/jdalrymple/node-hg-plus/status.svg)](https://david-dm.org/jdalrymple/node-test#info=dependencies) [![devDependency Status](https://david-dm.org/jdalrymple/node-hg-plus/dev-status.svg)](https://david-dm.org/jdalrymple/node-test#info=devDependencies)[![Code Climate](https://codeclimate.com/github/jdalrymple/node-hg-plus/badges/gpa.svg)](https://codeclimate.com/github/jdalrymple/node-hg-plus)[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)


# node-hg-plus

Expand Down
26 changes: 12 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,24 @@
"coverall": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js"
},
"devDependencies": {
"babel-eslint": "^7.1.1",
"babel-preset-latest": "^6.16.0",
"coveralls": "^2.11.15",
"eslint": "^4.3.0",
"eslint-config-airbnb": "^15.1.0",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-jsx-a11y": "^5.1.1",
"eslint-plugin-react": "^7.1.0",
"nyc": "^11.0.3",
"tape": "^4.6.3"
"coveralls": "^3.0.0",
"eslint": "^4.19.1",
"eslint-config-airbnb": "^16.1.0",
"eslint-plugin-import": "^2.11.0",
"eslint-plugin-jsx-a11y": "^6.0.3",
"eslint-plugin-react": "^7.7.0",
"nyc": "^11.7.1",
"tape": "^4.9.0"
},
"dependencies": {
"blue-tape": "^1.0.0",
"bluebird": "^3.5.1",
"dir-compare": "^1.4.0",
"fs-extra": "^4.0.2",
"globby": "^6.1.0",
"fs-extra": "^5.0.0",
"globby": "^8.0.1",
"is-there": "^4.4.3",
"shortid": "^2.2.8",
"tempy": "^0.1.0",
"winston": "^2.4.0"
"tempy": "^0.2.1",
"winston": "^2.4.2"
}
}
5 changes: 2 additions & 3 deletions src/Command.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use-strict';

const Exec = require('child_process').exec;
const Promise = require('bluebird');
const Utils = require('./Utils');
Expand All @@ -21,7 +19,7 @@ function run(command, directory = process.cwd(), options = []) {
});
}

async function runWithHandling(command, directory = process.cwd(), options = [], done){
async function runWithHandling(command, directory = process.cwd(), options = [], done) {
try {
const output = await run(command, directory, options);

Expand All @@ -30,6 +28,7 @@ async function runWithHandling(command, directory = process.cwd(), options = [],
return Utils.asCallback(output.error, output.stdout, done);
}
}

module.exports = {
run,
runWithHandling,
Expand Down
50 changes: 33 additions & 17 deletions src/Hg.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ async function getSourceInfo(source, pythonPath) {
let sourceURL = null;

if (source.constructor !== String && source.constructor !== Object) {
throw new TypeError('Incorrect type of from parameter. Clone source in the array is an invalid type. Must be an String or an Object');
throw new TypeError(
'Incorrect type of from parameter. Clone source in the array is an invalid type. Must be an String or an Object',
);
}

if (source.constructor === Object) sourceURL = source.url;
Expand All @@ -29,7 +31,11 @@ async function getSourceInfo(source, pythonPath) {

await cloneSingle(source, { path: sourceRepoPath, url: sourceURL }, pythonPath);
} catch (error) {
if (error.code !== 'ERR_INVALID_URL' && !(error.message && error.message.includes('Invalid URL'))) throw error;
if (
error.code !== 'ERR_INVALID_URL' &&
!(error.message && error.message.includes('Invalid URL'))
)
throw error;

sourceRepoPath = source;
sourceRepoName = Path.basename(source);
Expand All @@ -43,22 +49,27 @@ async function cloneSingle(from, to, pythonPath) {
let url;

if (from.constructor === Object) {
repo = new HgRepo(to || {
url: from.url,
password: from.password,
username: from.username,
}, pythonPath);
repo = new HgRepo(
to || {
url: from.url,
password: from.password,
username: from.username,
},
pythonPath,
);

url = Utils.buildRepoURL(from);
} else {
repo = new HgRepo(to || {
url: from,
}, pythonPath);
repo = new HgRepo(
to || {
url: from,
},
pythonPath,
);
url = from;
}

await Utils.ensureRepoPath(repo.path);

await Command.run('hg clone', repo.path, [url, repo.path]);

return repo;
Expand All @@ -69,10 +80,9 @@ async function cloneMultipleAndMerge(from, to, pythonPath) {
const combinedRepo = new HgRepo(to, pythonPath);

await Utils.ensureRepoPath(combinedRepo.path);

await combinedRepo.init();

await Promise.each(from, async (repo) => {
await Promise.each(from, async repo => {
const [repoName, repoPath] = await getSourceInfo(repo, pythonPath);
let repoDir = repoName;

Expand All @@ -83,7 +93,11 @@ async function cloneMultipleAndMerge(from, to, pythonPath) {
await combinedRepo.pull({ source: repoPath, force: true });
await combinedRepo.update({ clean: true, revision: 'default' });

const files = await Globby(['*', '!.hg'], { dot: true, cwd: combinedRepo.path });
const files = await Globby(['*', '!.hg'], {
onlyFiles: false,
dot: true,
cwd: combinedRepo.path,
});
const subDirectory = Path.join(combinedRepo.path, repoDir);

await Utils.moveFiles(combinedRepo.path, subDirectory, files);
Expand All @@ -106,8 +120,10 @@ async function cloneMultipleAndMerge(from, to, pythonPath) {
try {
await combinedRepo.commit(`Merging ${repoName} into combined`);
} catch (error) {
if (!error.message.includes('nothing to merge') &&
!error.message.includes('merging with a working directory ancestor')) {
if (
!error.message.includes('nothing to merge') &&
!error.message.includes('merging with a working directory ancestor')
) {
throw error;
}
}
Expand All @@ -117,7 +133,7 @@ async function cloneMultipleAndMerge(from, to, pythonPath) {
}

class Hg {
constructor({ path = 'python' } = { path: 'python' }) {
constructor({ path = 'python' } = {}) {
this.pythonPath = path;
}

Expand Down
Loading

0 comments on commit a2fb9be

Please sign in to comment.