-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathm2b
44 lines (41 loc) · 930 Bytes
/
m2b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
# input is a commit message
# output is a git branch name
function trimillegalends {
long=${1:0:100}
while true; do
good=true;
if [[ "$long" == */ ]] ; then
long=${long::-1}
good=false
fi
if [[ "$long" == *.lock ]] ; then
long=${long::-5}
good=false
fi
if $good ; then
break
fi
done
echo $long
}
exec sed \
-e 's|\.lock$|}L>|g' \
-e 's/@{/}C>/g' \
-e 's/^\./}0D>/g' \
-e 's?//?}S>?g' \
-e 's?/\.?}SD>?g' \
-e 's?\*?}SS>?g' \
-e 's/\^/=#=/g' \
-e 's/?/}.>/g' \
-e 's/~/}t>/g' \
-e 's/\]/))))/g' \
-e 's/\[/((((/g' \
-e 's/:/----/g' \
-e 's/ /_/g' \
-e 's/\.\./}DD>/g' \
-e 's/\\/}BSBS>/g' \
-e "s/"'"'"/_''_/g" \
-e "s/\.$/}dD>/g" \
-e "s|/$|}sD>|g" \
| (read long; trimillegalends $long )