Permalink
Browse files

Add "install" action to git-ts, adds post-commit handler inside a git…

… project.
  • Loading branch information...
1 parent 5ebafe4 commit 7c9b9e10c592de2cfcb8b54b6da981a75050bd62 @rektide committed Sep 6, 2011
Showing with 35 additions and 0 deletions.
  1. 0 bin/{publish → git-ts-publish}
  2. +35 −0 server.js
File renamed without changes.
View
@@ -5,6 +5,41 @@ var exec= require('child_process').exec,
spaces= /[\s]/,
pieces= [null,null]
+// this first section, install, builds post-commit files.
+if(process.argv[2] == 'install') {
+ var path= require('path'),
+ cwd= process.cwd()
+ dir= cwd
+ while(dir.length > 1) {
+ var trial= null,
+ git_dir= dir+"/.git/hooks"
+ try {
+ trial= fs.statSync(git_dir)
+ } catch(ex) {
+ }
+ if(trial && trial.isDirectory) {
+ dir= git_dir
+ break;
+ }
+ dir= path.dirname(dir)
+ }
+ if(dir.length <= 1) {
+ process.exit(1)
+ }
+
+ var dest= dir+"/post-commit"
+ try{
+ fs.statSync(dest)
+ dest= dest+".git-js-default"
+ }catch(ex){
+ }
+
+ fs.writeFileSync(dest,"#!/bin/sh\ngit-ts-publish")
+ process.exit()
+}
+
+process.exit(99)
+
exec('git log -n1', function(err,stdout,stdin) {
if(err) process.exit(2)
var head= stdout.split(spaces,2)[1]

0 comments on commit 7c9b9e1

Please sign in to comment.