File: patch_from_svn.sh

package info (click to toggle)
grimripper 3.0.2-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,312 kB
  • sloc: ansic: 7,483; xml: 81; sh: 42; makefile: 7
file content (46 lines) | stat: -rwxr-xr-x 896 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/env bash

patch_directory="../asunder_svn"

log_file="$patch_directory/svn_log.txt"


patch_file() {
    number=$1
    echo "$patch_directory/patch_$number.patch"
}

patch_date() {
    number=$1
    grep -r "^r$number" "$log_file" | awk -F'|' '{print $3}' | awk '{print $1" "$2}'
}

patch_message() {
    number=$1
    sed -n -e "/r$number/,/-----------------/ p" "$log_file" | sed -e '1d;2d;$d'
}


apply_all_patches() {
    first=$1
    last=$2

    for number in $(seq "$first" "$last"); do
        echo "Applying $number..."
        if ! git apply --exclude='releases/*' -p1 "$(patch_file "$number")"; then
            echo "Could not apply patch. Aborting."
            exit 1
        fi

        git commit -a \
            --author andrew \
            --date "$(patch_date "$number")" \
            --message "$(patch_message "$number")"

    done

}



apply_all_patches "$@"