Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions _ci/last-modified.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,27 @@ $0 ~ "---" && ++count == 2 {
date="$(date +'%Y-%m-%d %H:%M %z')"
awk 2>&1 | grep -q includefile && inplace=1 || inplace=0

while read -d $'\0' file; do
patchdate () {
if [ $inplace -eq 1 ]; then
awk -i inplace -v date="$date" "$awkcmd" "$file"
awk -i inplace -v date="$date" "$awkcmd" "$1"
else
tmp=$(mktemp)
awk -v date="$date" "$awkcmd" "$file" > "$tmp"
mv "$tmp" "$file"
awk -v date="$date" "$awkcmd" "$1" > "$tmp"
mv "$tmp" "$1"
fi
git add "$file" # @todo avoid committing any other changes
}

while read -d $'\0' file; do
# move file out and get rid of unstaged changes
tmp=$(mktemp)
cp "$file" "$tmp"
git restore "$file"

# patch and add the file
patchdate "$file"
git add "$file"

# restore the unstaged changes and reapply the patch
mv "$tmp" "$file"
patchdate "$file"
done