Skip to content

Commit

Permalink
Merge pull request #10 from eladb/yosefd-supporttimeoutoption
Browse files Browse the repository at this point in the history
use latest version of ctxobj
  • Loading branch information
eladb committed Mar 19, 2014
2 parents 91f4e3c + ae6ccd2 commit 443d0f5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions lib/girror.js
Expand Up @@ -182,23 +182,23 @@ function girror(remote, worktree, options, callback) {
return findremote(worktree, girrorfile, remote, function(err, remote) {
if (err) return callback(err);
if (!remote) return callback(new Error('`remote` url is required'));
var repo = remote;

// if remote contains a '#' treat the hash as a branch
if (remote.indexOf('#') !== -1) {
if (branch) throw new Error('cannot define branch both as a remote url hash and in options');

var _ = remote.split('#');
remote = _[0];
repo = _[0];
branch = _[1];
}

// parse remote using the remote parser
var remote_input = remote; // store for saving into girror file
remote = remote_type(remote);
var url = remote_type(repo);
if (!branch) branch = 'master'; // default branch in case it was not defined anywhere

// calc baredir name by replacing any non-fs chars in remote url.
var dirname = remote.replace(/[\\\/\:@\.]/g, '_');
var dirname = url.replace(/[\\\/\:@\.]/g, '_');
var dirpath = path.join(cachedir, dirname);

return function girrorseq(retry) {
Expand All @@ -211,11 +211,11 @@ function girror(remote, worktree, options, callback) {
$git(dirpath, ['init', '--bare']), // will not harm an existing repo

// git remote rm/add origin
$log('setting up remote origin to ' + remote),
$git(dirpath, ['remote', 'add', 'origin', '--mirror=fetch', remote], true), // ignore errors (in case remote already exist)
$log('setting up remote origin to ' + url),
$git(dirpath, ['remote', 'add', 'origin', '--mirror=fetch', url], true), // ignore errors (in case remote already exist)

// git fetch origin
$log('fetching updates from ' + remote),
$log('fetching updates from ' + url),
$if(
depth === -1,
$git(dirpath, [ 'fetch', 'origin' ]),
Expand All @@ -237,7 +237,7 @@ function girror(remote, worktree, options, callback) {
$mkdirp(worktree),
$git(dirpath, [ '--work-tree', worktree, 'checkout', '-f', branch ]),
// create girrorfile
$girrorfile(worktree, girrorfile, remote_input, branch)
$girrorfile(worktree, girrorfile, repo, branch)
])
)
], function(err) {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -2,7 +2,7 @@
"author": "Elad Ben-Israel <elad.benisrael@gmail.com>",
"name": "girror",
"description": "Efficient mirror of git repositories. Great for continuous deployment",
"version": "0.2.11",
"version": "0.2.12",
"contributors": [ "Yosef Dinerstein <yosefd@microsoft.com>" ],
"repository": {
"type": "git",
Expand All @@ -18,7 +18,7 @@
"dependencies": {
"mkdirp": "0.3.x",
"async": "0.1.x",
"ctxobj": "0.2.x",
"ctxobj": "0.3.x",
"commander": "0.5.x",
"logule": "0.6.x",
"rimraf": "2.0.x"
Expand Down

0 comments on commit 443d0f5

Please sign in to comment.