Permalink
Browse files

add ability to set branch to repos

  • Loading branch information...
1 parent 7b10a30 commit 374a66872261a0d18648f9af84ea7d7b092f2276 @crcn crcn committed Dec 9, 2011
Showing with 261 additions and 58 deletions.
  1. +3 −3 README.md
  2. +6 −2 bin/gittyup
  3. +4 −3 lib/app.js
  4. +28 −6 lib/checkout/git.js
  5. +1 −1 package.json
  6. +219 −43 project.sublime-workspace
View
@@ -1,9 +1,9 @@
-Gittyup is a small node.js application deployment library similar to [n](/visionmedia/n)
+Gittyup is a small node.js application deployment library similar to [n](/visionmedia/n).
### Features
-- Command LIne Interface
+- Command Line Interface.
- Rollback support.
- Script testing before using.
- Start/Stop/Restart checked out apps.
@@ -12,7 +12,7 @@ Gittyup is a small node.js application deployment library similar to [n](/vision
## Command Line
- gup checkout daisy --repo=https://github.com/crcn/daisy.git
+ gup checkout daisy --repo=https://github.com/crcn/daisy.git --branch=app-branch
gup use daisy r5 #use a particular checkout
### Options
View
@@ -15,15 +15,19 @@ celeri.onCommand({ command: 'checkout :name :repo OR checkout :name', desc: 'che
var data = this.data,
name = data.name,
gap = gup(name, data.records || 20),
- repo = decodeURIComponent(data.repo || cfg.get(name+':repository'));
+ repo = decodeURIComponent(data.repo || cfg.get(name+':repository')),
+ branch = data.branch || cfg.get(name+':branch');
- var em = gap.checkout(repo, function(err, result) {
+ var em = gap.checkout({ repository: repo, branch: branch }, function(err, result) {
cfg.set(name+':repository', repo);
+ cfg.set(name+':branch', branch);
gap.process(function(err, process) {
+ if(err) return console.error(err);
+
process.restart(function(err, result) {
});
View
@@ -69,14 +69,15 @@ var App = Structr({
*/
'checkout': function(ops, callback) {
- var source, start, em = new EventEmitter();
+ var source, start, branch, em = new EventEmitter();
if(typeof ops == 'string') {
source = ops;
ops = {};
} else {
start = ops.start;
source = ops.repository;
+ branch = ops.branch;
}
if(!callback) callback = function(){};
@@ -103,9 +104,9 @@ var App = Structr({
self.current(function(err, previous) {
//checkout the source which could be from a number of sources
- var ret = checkout({ source: source, app: self, output: appDir }, function(err, response) {
+ var ret = checkout({ source: source, app: self, output: appDir, branch: branch }, function(err, response) {
em.emit('data', 'checked out: ' + source);
-
+
if(err) return callback(err, response ? response.result : undefined);
View
@@ -7,11 +7,10 @@ exports.test = function(ops) {
return ops.source.split('.').pop() == 'git';
}
-exports.checkout = function(ops, callback) {
- console.log('using git to check out ' + ops.source);
-
- var git = spawn('git',[ 'clone',ops.source,ops.output], { cwd: __dirname }),
- em = new EventEmitter(),
+function execute(args, ops, callback) {
+
+ var git = spawn(args.shift(), args, { cwd: ops.cwd }),
+ em = ops.em,
err = false;
@@ -21,12 +20,35 @@ exports.checkout = function(ops, callback) {
git.stderr.on('data', function(data) {
em.emit('error', data.toString());
- err = true;
+ // err = true;
})
git.on('exit', function() {
callback(err, { result: true, link: true });
});
+}
+
+
+exports.checkout = function(ops, callback) {
+ console.log('using git to check out ' + ops.source);
+
+ var em = new EventEmitter();
+
+
+ execute(['git'].concat([ 'clone', ops.source, ops.output]), { cwd: __dirname, em: em }, function(err, result) {
+
+ if(err) return callback(err, result);
+
+
+ if(ops.branch) {
+ console.log('Switching branch');
+
+ execute(['git','checkout', ops.branch], { cwd: ops.output, em: em }, callback);
+ } else {
+ callback(err, result);
+ }
+ })
+
return em;
}
View
@@ -1,7 +1,7 @@
{
"name": "gittyup",
"descriptions": "easy git deployment for node.js apps",
- "version": "0.1.2",
+ "version": "0.1.4",
"author": "Craig Condon <craig@crcn.com>",
"repository": {
"type": "git",
Oops, something went wrong.

0 comments on commit 374a668

Please sign in to comment.