Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added shell script to sync all git post-receive hooks with the latest…

… gitrepoclone.sh
  • Loading branch information...
commit aaaf4d3c4965031b1d5b87cde7c16d7944e4189b 1 parent f888d4c
@davglass davglass authored
Showing with 55 additions and 0 deletions.
  1. +13 −0 bin/sync_githook.sh
  2. +42 −0 scripts/sync_githook.js
View
13 bin/sync_githook.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+cd `dirname $0`
+
+./node-config.js
+wait
+source ./.nodester.config
+
+export HOME=$HOME_DIR;
+export PATH="/usr/local/bin:${PATH}";
+
+$APP_DIR/scripts/sync_githook.js
+
View
42 scripts/sync_githook.js
@@ -0,0 +1,42 @@
+#!/usr/bin/env node
+
+var path = require('path');
+var fs = require('fs');
+var config = require('../config').opt;
+var hosted = path.join(config.home_dir, config.hosted_apps_subdir);
+var exists = path.existsSync;
+var util = require('util');
+process.chdir(hosted);
+require('colors');
+util.print('Reading git repos:'.magenta);
+var src = path.join(config.app_dir, 'scripts', 'gitrepoclone.sh');
+var copy = function() {
+ if (repos.length) {
+ var dest = repos.pop();
+ var is = fs.createReadStream(src);
+ var os = fs.createWriteStream(dest);
+ util.pump(is, os, copy);
+ } else {
+ util.print(' [done]\n'.white);
+ }
+}
+
+var repos = [];
+var dirs = fs.readdirSync('.');
+dirs.forEach(function(v) {
+ if (exists(v)) {
+ var stat = fs.statSync(v);
+ if (stat.isDirectory()) {
+ var dirs = fs.readdirSync(v);
+ dirs.forEach(function(i) {
+ if (path.extname(i) === '.git') {
+ repos.push(path.join(hosted, v, i, 'hooks', 'post-receive'));
+ }
+ });
+ }
+ }
+});
+util.print((' (' + dirs.length + ')').yellow + ' [done]\n'.white);
+util.print('Processing git commit hooks'.magenta);
+copy();
+
Please sign in to comment.
Something went wrong with that request. Please try again.