You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2014/04/24 17:50:14 UTC
git commit: repo-clone module
Repository: cordova-coho
Updated Branches:
refs/heads/master 478366033 -> 6c10b474d
repo-clone module
Project: http://git-wip-us.apache.org/repos/asf/cordova-coho/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-coho/commit/6c10b474
Tree: http://git-wip-us.apache.org/repos/asf/cordova-coho/tree/6c10b474
Diff: http://git-wip-us.apache.org/repos/asf/cordova-coho/diff/6c10b474
Branch: refs/heads/master
Commit: 6c10b474d8eb28d58ba82cf26149e05f88cfe9de
Parents: 4783660
Author: Andrew Grieve <ag...@chromium.org>
Authored: Thu Apr 24 11:50:00 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Thu Apr 24 11:50:00 2014 -0400
----------------------------------------------------------------------
src/main.js | 46 ++-------------------------------
src/repo-clone.js | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 71 insertions(+), 44 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/6c10b474/src/main.js
----------------------------------------------------------------------
diff --git a/src/main.js b/src/main.js
index f694c19..db2fff7 100644
--- a/src/main.js
+++ b/src/main.js
@@ -70,10 +70,6 @@ function *gitCheckout(branchName) {
}
}
-function createRepoUrl(repo) {
- return 'https://git-wip-us.apache.org/repos/asf/' + repo.repoName + '.git';
-}
-
function *localBranchExists(name) {
return !!(yield executil.execHelper(executil.ARGS('git branch --list ' + name), true));
}
@@ -104,44 +100,6 @@ function retrieveCurrentTagName() {
return executil.execHelper(executil.ARGS('git describe --tags HEAD'), true, true);
}
-function *repoCloneCommand(argv) {
- var opt = flagutil.registerRepoFlag(optimist)
- opt = flagutil.registerHelpFlag(opt);
- var argv = opt
- .usage('Clones git repositories into the current working directory. If the repositories are already cloned, then this is a no-op.\n\n' +
- 'Usage: $0 clone --repo=name [--repo=othername]')
- .argv;
-
- if (argv.h) {
- optimist.showHelp();
- process.exit(1);
- }
- var repos = flagutil.computeReposFromFlag(argv.r);
- yield cloneRepos(repos, false);
-}
-
-function *cloneRepos(repos, quiet) {
- var failures = [];
- var numSkipped = 0;
-
- for (var i = 0; i < repos.length; ++i) {
- var repo = repos[i];
- if (shjs.test('-d', repo.repoName)) {
- if(!quiet) print('Repo already cloned: ' + repo.repoName);
- numSkipped +=1 ;
- } else if (repo.svn) {
- yield executil.execHelper(executil.ARGS('svn checkout ' + repo.svn + ' ' + repo.repoName));
- } else {
- yield executil.execHelper(executil.ARGS('git clone --progress ' + createRepoUrl(repo)));
- }
- }
-
- var numCloned = repos.length - numSkipped;
- if (numCloned) {
- print('Successfully cloned ' + numCloned + ' repositories.');
- }
-}
-
function *repoStatusCommand(argv) {
var opt = flagutil.registerRepoFlag(optimist)
var opt = optimist
@@ -376,7 +334,7 @@ function *repoUpdateCommand(argv) {
var repos = flagutil.computeReposFromFlag(argv.r);
// ensure that any missing repos are cloned
- yield cloneRepos(repos,true);
+ yield require('./repo-clone').cloneRepos(repos,true);
yield updateRepos(repos, branches, !argv.fetch);
}
@@ -684,7 +642,7 @@ function main() {
{
name: 'repo-clone',
desc: 'Clones git repositories into the current working directory.',
- entryPoint: repoCloneCommand
+ entryPoint: require('./repo-clone')
}, {
name: 'repo-update',
desc: 'Performs git pull --rebase on all specified repositories.',
http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/6c10b474/src/repo-clone.js
----------------------------------------------------------------------
diff --git a/src/repo-clone.js b/src/repo-clone.js
new file mode 100644
index 0000000..a0936dd
--- /dev/null
+++ b/src/repo-clone.js
@@ -0,0 +1,69 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+*/
+
+var fs = require('fs');
+var optimist = require('optimist');
+var apputil = require('./apputil');
+var executil = require('./executil');
+var flagutil = require('./flagutil');
+var print = apputil.print;
+
+module.exports = function*(argv) {
+ var opt = flagutil.registerRepoFlag(optimist)
+ opt = flagutil.registerHelpFlag(opt);
+ var argv = opt
+ .usage('Clones git repositories into the current working directory. If the repositories are already cloned, then this is a no-op.\n\n' +
+ 'Usage: $0 clone --repo=name [--repo=othername]')
+ .argv;
+
+ if (argv.h) {
+ optimist.showHelp();
+ process.exit(1);
+ }
+ var repos = flagutil.computeReposFromFlag(argv.r);
+ yield cloneRepos(repos, false);
+}
+
+function createRepoUrl(repo) {
+ return 'https://git-wip-us.apache.org/repos/asf/' + repo.repoName + '.git';
+}
+
+function *cloneRepos(repos, quiet) {
+ var failures = [];
+ var numSkipped = 0;
+
+ for (var i = 0; i < repos.length; ++i) {
+ var repo = repos[i];
+ if (fs.existsSync(repo.repoName)) {
+ if(!quiet) print('Repo already cloned: ' + repo.repoName);
+ numSkipped +=1 ;
+ } else if (repo.svn) {
+ yield executil.execHelper(executil.ARGS('svn checkout ' + repo.svn + ' ' + repo.repoName));
+ } else {
+ yield executil.execHelper(executil.ARGS('git clone --progress ' + createRepoUrl(repo)));
+ }
+ }
+
+ var numCloned = repos.length - numSkipped;
+ if (numCloned) {
+ print('Successfully cloned ' + numCloned + ' repositories.');
+ }
+}
+module.exports.cloneRepos = cloneRepos;
+