-
Notifications
You must be signed in to change notification settings - Fork 14
/
url_diff.sh
executable file
·45 lines (40 loc) · 1.17 KB
/
url_diff.sh
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
45
#!/usr/bin/env bash
old="$(nix build --print-out-paths --no-link github:gelos-icmc/site)/public"
new="$(nix build --print-out-paths --no-link)/public"
# Ignorar PDFs
diff="$(diff "$old" "$new" -qr | grep -v '\.pdf')"
modified="$(echo "$diff" | grep "Files .* differ")"
if [ -n "$modified" ]; then
echo "Caminhos modificados:";
fi
while IFS= read -r line; do
# Limpar path, obter só URL relativo
path="$(echo $line | cut -d ' ' -f2)"
path="${path#"$old/"}"
# Adicionar ao output
if [ -n "$path" ]; then
echo "- [/$path]($base_url/$path)"
fi
done <<< "$modified"
added="$(echo "$diff" | grep "Only in $new")"
if [ -n "$added" ]; then
echo ""
echo "Caminhos adicionados";
fi
while IFS= read -r line; do
path="$(echo $line | sed -E 's|Only in .+(/public)?(/[^/]+): (.*)|\2/\3|')"
if [ -n "$path" ]; then
echo "- [$path]($base_url$path)"
fi
done <<< "$added"
removed="$(echo "$diff" | grep "Only in $old")"
if [ -n "$removed" ]; then
echo ""
echo "Caminhos removidos:";
fi
while IFS= read -r line; do
path="$(echo $line | sed -E 's|Only in .+(/public)?(/[^/]+): (.*)|\2/\3|')"
if [ -n "$path" ]; then
echo "- $path"
fi
done <<< "$removed"