githelper.git
/
githelper.pike
version
»
Context lines:
10
20
40
80
file
none
3
githelper.git/githelper.pike:1:
#! /usr/bin/env pike
+
#define DOLLAR "$"
+
constant unexpanded_id = DOLLAR"Id"DOLLAR;
+
mapping(string:program) hooks = ([ "pre-commit" : PreCommitHook, "pre-receive" : PreReceiveHook, ]); mapping(string:program) filters = ([ #if 0 "nice_ident" : NiceIdentFilter, #endif ]);
githelper.git/githelper.pike:232:
static array(string) files_to_commit; GitAttributes attrs; string get_file(string filename, int|void allow_empty); string get_old_file(string filename, int|void allow_empty); int entry_is_new(string filename) { return 0; } int find_expanded_ident(string data) { int p=0;
-
while ((p = search(data, "
$Id
", p))>=0) {
-
if (data[p..p+3] !=
"$Id$"
)
+
while ((p = search(data,
DOLLAR
"
Id
", p))>=0) {
+
if (data[p..p+3] !=
unexpanded_id
)
return 1; p += 4; } return 0; } int check_ident(string filename) { if (find_expanded_ident(get_file(filename))) { write("File %s contains an expanded ident.\n", filename);
githelper.git/githelper.pike:434:
} /* 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);
+
while((p=search(f,
DOLLAR
"
Id
", p)) >= 0) {
+
int p2 = search(f,
DOLLAR
, 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); f = f[..p-1]+r+f[p2+1..]; p += sizeof(r); } else { // werror("Not replacing %O\n", f[p..p2]); p = p2+1; } } else p += 3; } return f; } static string clean_ident(string i) {
-
if(has_prefix(i, "
$Id
:") && sizeof(i/" ")==13)
-
return
"$Id$"
;
+
if(has_prefix(i,
DOLLAR
"
Id
:") && sizeof(i/" ")==13)
+
return
unexpanded_id
;
} static string smudge_ident(string i) {
-
return "
$Id$
";
+
return
DOLLAR
"
Id: some nice ident perhaps, but based on what?
"
DOLLAR
;
} int clean() { write(replace_id(Stdio.stdin->read(), clean_ident)); return 0; } int smudge() {