/
patchsets
executable file
·87 lines (56 loc) · 1.3 KB
/
patchsets
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env bash
rvm_base_except="selector"
source "$rvm_path/scripts/base"
source "$rvm_path/scripts/patches"
lookup_patchset()
{
local paths lookup_path
if [[ -z "$1" ]]; then
echo "Usage: rvm patchset show name"
return 1
fi
paths=($(__rvm_ruby_string_paths_under "$rvm_path/patchsets"))
for lookup_path in "${paths[@]}" ; do
if [[ -s "$lookup_path/$1" ]]; then
cat "$lookup_path/$1"
return 0
fi
done
return 1
}
# Return the full patch for a given patch.
__rvm_lookup_full_patch_path()
{
local directory directories extension patch_path
directories=($(__rvm_patch_lookup_path))
# Absolute path, pwd and then finally the rvm patches path.
for directory in "${directories[@]}" ; do
for extension in {"",.patch,.diff}; do
patch_path="${directory}${1}${extension}"
if [[ -s "$patch_path" ]]; then
echo "$patch_path"
return
fi
done
done
return 1
}
usage()
{
printf "
Usage:
rvm patchset {show,lookup} [patchset]
Description:
Tools for manipulating patchsets.
"
return 1
}
args=($*)
action="${args[0]}"
patchset="${args[1]}"
args="$(echo ${args[@]:2}) " # Strip trailing / leading / extra spacing.
case "$action" in
show|lookup) lookup_patchset "$patchset" ;;
*) usage ;;
esac
exit $?