githelper.git / githelper.pike

version» Context lines:

githelper.git/githelper.pike:1:   #! /usr/bin/env pike      constant hooks = ([ -  "post-checkout" : PostCheckoutHook, +  "pre-commit" : PreCommitHook,   ]);      constant filters = ([    "nice_ident" : NiceIdentFilter,   ]);            constant filterops = ({ "clean", "smudge" });   
githelper.git/githelper.pike:38:    return res->stdout;   }      string run_git(string ... args)   {    return run_git_ex(0, @args);   }      /* Hooks */    - class PostCheckoutHook + /* Checks run before editing a commit message */ +  + class PreCommitHook   { -  int hook(string old_head, string new_head, string branchflag) +  int hook()    { -  write("post-checkout: old=%s, new=%s, branch=%d\n", -  old_head, new_head, (int)branchflag); +  write("pre-commit\n");    return 0;    }   }      /* Filters */    -  + /* A sample filter, not really useful... */ +    class NiceIdentFilter   {    static string replace_id(string f, function(string:string) replace) {    int p=0;    while((p=search(f, "$Id", p)) >= 0) {    int p2 = search(f, "$", p+3), p3 = search(f, "\n", p+3);    if (p2 > p && p2 < p3) {    string r = replace(f[p..p2]);    if (r) {    // werror("Replacing %O with %O\n", f[p..p2], r);
githelper.git/githelper.pike:118:    }    foreach (hooks; string name; ) {    string path = combine_path(hooksdir, name);    Stdio.Stat s = file_stat(path, 1);    if (!s) {    write("Installing %s\n", path);    System.symlink(__FILE__, path);    } else if (s->islnk) {    /* Already setup ok, it seems */    } else { -  write("Hook %s already exists, so won't overwrite it...", name); +  write("Hook %s already exists, so won't overwrite it...\n", name);    }    }    }       void setup_filter(string name, string op)    {    string confname = "filter."+name+"."+op;    string old = String.trim_all_whites(run_git_ex(1, "config", "--get", confname));    string cmd = __FILE__+" filter_"+name+"_"+op;    if (old == "") {