-
Notifications
You must be signed in to change notification settings - Fork 6
/
links.sh
executable file
·47 lines (37 loc) · 1.01 KB
/
links.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
46
47
#!/bin/bash
#
# ./links.sh [common] [-s] COMMIT
# Git diff to links.
# Does not do any changes.
#
# Details: works on website/content repository,
# compares current commit against with one supplied in argument.
#
# For common options, see './common.sh -h'.
#
# -s output for staging server
#
. $(dirname "`readlink -e "$0"`")/common.sh &>/dev/null || exit 1
U1='https://developer.'
U2='fedoraproject.org/'
stg=
ind=
c=0
br=release
[[ "$1" == '-s' ]] && { stg='stg.' ; ind=' ' ; shift ; }
[[ -n "$1" ]] || die "Commit missing"
URL="$U1$stg$U2"
scd "website/content"
set -o pipefail
git diff --stat "$1" \
| head -n -1 \
| sed -e 's/^[\. ]*//g' \
| cut -d' ' -f1 \
| xargs -i bash -c "
f='{}'
[[ -r \"\$f\" ]] || \
f=\"\$( find -name \"\$(basename \"\$f\")\" | grep \"\$f$\" | head -1 | cut -d'/' -f2- )\"
[[ -r \"\$f\" ]] || exit 255
f=\"\$(rev <<< \"\$f\" | cut -d'.' -f2- | rev)\"
echo \" ${URL}\${f}.html\"
"