Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
aaoSystem
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
rds
aaoSystem
Commits
dec317bb
Commit
dec317bb
authored
4 years ago
by
afarrell
Browse files
Options
Downloads
Patches
Plain Diff
Manually case-insensitive regexes making up for macOS sed lack of i flag
parent
9e6c3bf1
Branches
Branches containing commit
Tags
2.5
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
rcs-keywords.clean
+3
-5
3 additions, 5 deletions
rcs-keywords.clean
rcs-keywords.smudge
+27
-12
27 additions, 12 deletions
rcs-keywords.smudge
with
30 additions
and
17 deletions
rcs-keywords.clean
+
3
−
5
View file @
dec317bb
...
...
@@ -51,15 +51,13 @@ fi
#
#The | alternation and (capture) must be escaped because
#these aren't extended regexes.
regex
=
'\$\(author\|date\|header\|id\|locker\|log\|RCSfile\|revision\|source\|state\):[^$]*\$'
#Case insensitive version of regex='\$\(author\|date\|header\|id\|locker\|log\|RCSfile\|revision\|source\|state\):[^$]*\$'
regex
=
'\$\([aA][uU][tT][hH][oO][rR]\|[dD][aA][tT][eE]\|[hH][eE][aA][dD][eE][rR]\|[iI][dD]\|[lL][oO][cC][kK][eE][rR]\|[lL][oO][gG]\|[rR][cC][sS][fF][iI][lL][eE]\|[rR][eE][vV][iI][sS][iI][oO][nN]\|[sS][oO][uU][rR][cC][eE]\|[sS][tT][aA][tT][eE]\):[^$]*\$'
#Escapes both '$' in this replacement
#Also the \1 is escaped
#gi: Case insensitive, replace *all* instances
sedscript
=
"s/
$regex
/
\$\\
1
\$
/g
i
"
sedscript
=
"s/
$regex
/
\$\\
1
\$
/g"
regex
=
'\$\(author\|date\|header\|id\|locker\|log\|RCSfile\|revision\|source\|state\):[^$]*\$'
sedscript
=
"s/
$regex
/
\$\\
1
\$
/gi"
sed
"
$sedscript
"
"
$tmp
"
;
rm
"
$tmp
"
;
This diff is collapsed.
Click to expand it.
rcs-keywords.smudge
+
27
−
12
View file @
dec317bb
...
...
@@ -97,34 +97,49 @@ date="$(git log --pretty='%aD' -- "$abspath" | head -n1 |
sed
-Ee
's/^([A-Z][a-z][a-z]), ([123]?[0-9]) ([A-Z][a-z][a-z]) ([0-9]+) ([0-2][0-9]:[0-5][0-9]:[0-5][0-9]) \+([0-9][0-9])[0-9][0-9]/\2-\3\-4 \5+\6/g'
|
head
-n1
)
"
#Clean then convert. This regex same as rcs-keywords.clean
regex
=
'\$\(author\|date\|header\|id\|locker\|log\|RCSfile\|revision\|source\|state\):[^$]*\$'
#Case insensitive version of regex='\$\(author\|date\|header\|id\|locker\|log\|RCSfile\|revision\|source\|state\):[^$]*\$'
regex
=
'\$\([aA][uU][tT][hH][oO][rR]\|[dD][aA][tT][eE]\|[hH][eE][aA][dD][eE][rR]\|[iI][dD]\|[lL][oO][cC][kK][eE][rR]\|[lL][oO][gG]\|[rR][cC][sS][fF][iI][lL][eE]\|[rR][eE][vV][iI][sS][iI][oO][nN]\|[sS][oO][uU][rR][cC][eE]\|[sS][tT][aA][tT][eE]\):[^$]*\$'
#We clean before doing any substitution
sedscriptclean
=
"s/
$regex
/
\$\\
1
\$
/g
i
"
sedscriptclean
=
"s/
$regex
/
\$\\
1
\$
/g"
#RCS Keyword substitution:
#Note that the \1 is used in all substitutions to preserve case of the keyword
#For each keyword, substitute the $Keyword.*$ with $Keyword: keyword value$ using 1 sed expression each
#\1 is used in all substitutions to preserve case of the keyword
#I switch from 'single quotes' to "double quotes" to better use escapes for the pattern, then use variables
sedscriptauthor
=
's@\$\(author\)\$@$\1: '
"
$(
sedescape
"
$author
\$
"
)
@gi"
#Case insensitive version of 's@\$\(author\)\$@$\1: '
sedscriptauthor
=
's@\$\([aA][uU][tT][hH][oO][rR]\)\$@$\1: '
"
$(
sedescape
"
$author
\$
"
)
@g"
# Since there is no such thing as locker, we do this instead
# But I haven't seen locker used in real-world ACMM yet, so not sure if this wo`uld work
sedscriptlocker
=
's@\$\(locker\)\$@$\1: '
"
$(
sedescape
"
$(
git config user.email
)
\$
"
)
@gi"
#Case insensitive version of 's@\$\(locker\)\$@$\1: '
sedscriptlocker
=
's@\$\([lL][oO][cC][kK][eE][rR]\)\$@$\1: '
"
$(
sedescape
"
$(
git config user.email
)
\$
"
)
@g"
#Case insensitive version of 's@\$\(date\)\$@$\1: '
sedscriptdate
=
's@\$\([dD][aA][tT][eE]\)\$@$\1: '
"
$(
sedescape
"
$date
\$
"
)
@g"
sedscriptdate
=
's@\$\(date\)\$@$\1: '
"
$(
sedescape
"
$date
\$
"
)
@gi"
sedscriptrevision
=
's@\$\(
revision
\)\$@$\1: '
"
$(
sedescape
"
$commit
\$
"
)
@g
i
"
#Case insensitive version of 's@\$\(revision\)\$@$\1: '
sedscriptrevision
=
's@\$\(
[rR][eE][vV][iI][sS][iI][oO][nN]
\)\$@$\1: '
"
$(
sedescape
"
$commit
\$
"
)
@g"
# Difference is abspath/relpath
sedscriptid
=
's@\$\(id\)\$@$\1: '
"
$(
sedescape
"GIT:
$relpath
,
$commit
$date
$author
\$
"
)
@gi"
sedscriptheader
=
's@\$\(header\)\$@$\1: '
"
$(
sedescape
"GIT:
$abspath
,
$commit
$date
$author
\$
"
)
@gi"
#Case insensitive version of 's@\$\(id\)\$@$\1: '
sedscriptid
=
's@\$\([iI][dD]\)\$@$\1: '
"
$(
sedescape
"GIT:
$relpath
,
$commit
$date
$author
\$
"
)
@g"
#Case insensitive version of 's@\$\(header\)\$@$\1: '
sedscriptheader
=
's@\$\([hH][eE][aA][dD][eE][rR]\)\$@$\1: '
"
$(
sedescape
"GIT:
$abspath
,
$commit
$date
$author
\$
"
)
@g"
# Difference is abspath/relpath
sedscriptrcsfile
=
's@\$\(rcsfile\)\$@$\1: '
"
$(
sedescape
"
$(
basename
"
$relpath
"
)
\$
"
)
@gi"
sedscriptsource
=
's@\$\(source\)\$@$\1: '
"
$(
sedescape
"
$abspath
\$
"
)
@gi"
#Case insensitive version of 's@\$\(rcsfile\)\$@$\1: '
sedscriptrcsfile
=
's@\$\([rR][cC][sS][fF][iI][lL][eE]\)\$@$\1: '
"
$(
sedescape
"
$(
basename
"
$relpath
"
)
\$
"
)
@g"
#Case insensitive version of 's@\$\(source\)\$@$\1: '
sedscriptsource
=
's@\$\([sS][oO][uU][rR][cC][eE]\)\$@$\1: '
"
$(
sedescape
"
$abspath
\$
"
)
@g"
# I Have not seen $Log$ actually used, just in comments only,
# I think ACMM might have something bad with its format of it.
# I have removed the ',v '
sedscriptlog
=
's@\$\(log\)\$@$\1: '
"
$(
sedescape
"
$(
basename
$relpath
)
\$
"
)
@gi"
#Case insensitive version of 's@\$\(log\)\$@$\1: '
sedscriptlog
=
's@\$\([lL][oO][gG]\)\$@$\1: '
"
$(
sedescape
"
$(
basename
$relpath
)
\$
"
)
@g"
sed
-e
"
$sedscriptclean
"
\
-e
"
$sedscriptauthor
"
\
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment