githelper.git/
githelper.pike
Branch:
Tag:
Non-build tags
All tags
No tags
2010-09-26
2010-09-26 20:46:29 by Marcus Comstedt <marcus@mc.pp.se>
c5289647f5c512ee5abf87c385c2605a937da254 (
18
lines) (+
11
/-
7
)
[
Show
|
Annotate
]
Branch:
master
Prevent code working with idents from being munged by the ident handling itself...
1:
#! /usr/bin/env pike
+
#define DOLLAR "$"
+
constant unexpanded_id = DOLLAR"Id"DOLLAR;
+
mapping(string:program) hooks = ([ "pre-commit" : PreCommitHook, "pre-receive" : PreReceiveHook,
239:
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; }
441:
{ 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) {
460:
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()