File tree Expand file tree Collapse file tree 1 file changed +19
-5
lines changed
Expand file tree Collapse file tree 1 file changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -11,13 +11,27 @@ $0 ~ "---" && ++count == 2 {
1111date=" $( date +' %Y-%m-%d %H:%M %z' ) "
1212awk 2>&1 | grep -q includefile && inplace=1 || inplace=0
1313
14- while read -d $' \0 ' file ; do
14+ patchdate () {
1515 if [ $inplace -eq 1 ]; then
16- awk -i inplace -v date=" $date " " $awkcmd " " $file "
16+ awk -i inplace -v date=" $date " " $awkcmd " " $1 "
1717 else
1818 tmp=$( mktemp)
19- awk -v date=" $date " " $awkcmd " " $file " > " $tmp "
20- mv " $tmp " " $file "
19+ awk -v date=" $date " " $awkcmd " " $1 " > " $tmp "
20+ mv " $tmp " " $1 "
2121 fi
22- git add " $file " # @todo avoid committing any other changes
22+ }
23+
24+ while read -d $' \0' file; do
25+ # move file out and get rid of unstaged changes
26+ tmp=$( mktemp)
27+ cp " $file " " $tmp "
28+ git restore " $file "
29+
30+ # patch and add the file
31+ patchdate " $file "
32+ git add " $file "
33+
34+ # restore the unstaged changes and reapply the patch
35+ mv " $tmp " " $file "
36+ patchdate " $file "
2337done
You can’t perform that action at this time.
0 commit comments