-
Notifications
You must be signed in to change notification settings - Fork 1
/
release.sh
executable file
·130 lines (107 loc) · 3.42 KB
/
release.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
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/bin/bash
# Script for automatically exporting diff in the correct format for all patches
# Usage:
# $1: if 1: export patch files.
# $2: if 1: export meta patches.
# Should both be true.
# Prior to executing, make sure that
# (1) mkdir patches
# (2) you checked out all the available branches.
set -e
if [[ ! -e patches ]]; then mkdir patches; fi
# Human-readable names of the different patches
namePatchHistory="history"
namePatchCols="columns"
namePatchScrollback="scrollback"
namePatchSel="selection"
namePatchRepaint="repaint"
namePatchVim="vim-browse"
# arguments: whether to generate raw patches and meta patches.
exportRaw=$1
exportMeta=$2
base=$3
# Return the name of the generated patch file.
getPatchFileName() {
patchName=$1
branchBase=$2
useCommit=$3
commitBase=$(git rev-parse --short $branchBase)
base=""
if [[ $useCommit -eq 1 ]]; then
base=$commitBase
else
base=$branchBase
fi
cdate=$(date "+%Y%m%d")
patchFile="patches/st-$patchName-$cdate-$base.diff"
echo $patchFile
}
# Generate a patch from the git repo.
origPatch() {
patchName=$1
branchChanges=$2
branchBase=$3
useCommit=$4
git checkout $branchChanges
git checkout $branchBase
patchOutputFile=$(getPatchFileName $patchName $branchBase $useCommit)
git checkout -b tmpSquash
git merge --squash $branchChanges
git commit -am "patch: $patchName"
git format-patch --stdout $branchBase > $patchOutputFile
git checkout master
git branch -D tmpSquash
echo "output: $patchOutputFile"
}
# Generate meta patches from the patches generated above.
metaPatch() {
metaPatchName="meta-$1"
branchBase=$2
useCommit=$3
tmpBranch=tmp-$metaPatchName
patchOutputFile=$(getPatchFileName $metaPatchName $branchBase $useCommit)
# Go to the base branch and branch off the tmpBranch
git checkout $branchBase
if git show-ref --quiet refs/heads/$tmpBranch; then
git branch -D $tmpBranch
fi
git checkout -b $tmpBranch
for name in "${@:4}"; do
patchFile=$(ls -Ar patches/st-$name* 2> /dev/null | head -n 1)
if [[ -z "$patchFile" ]]; then
echo "Error: patch file for $name not found. Abort."
exit
else
echo -e "patch file: $name:\t $patchFile"
fi
patch -p1 < $patchFile
done
git add *.c *.h
if [[ -f "config.h" ]]; then
rm config.h
fi
git commit -am "meta-patch: $patchName"
git format-patch --stdout $branchBase > $patchOutputFile
git checkout master
echo "meta-output: $patchOutputFile from $tmpBranch"
}
if [ -z "$base" ]; then
base=st-0.8.3
else
echo "Base: $base"
fi
# 'raw' single patches
if [[ $exportRaw -eq 1 ]]; then
origPatch $namePatchHistory historyVanilla $base 1
origPatch $namePatchCols patch_column historyVanilla 0
origPatch $namePatchScrollback patch_scrollback historyVanilla 0
origPatch $namePatchVim patch_vim historyVanilla 0
origPatch $namePatchRepaint patch_repaint historyVanilla 0
fi
if [[ $exportMeta -eq 1 ]]; then
metaPatch "scrollback" $base 1 $namePatchHistory $namePatchScrollback
metaPatch "scrollback-full" $base 1 $namePatchHistory $namePatchCols $namePatchScrollback
metaPatch "vim" $base 1 $namePatchHistory $namePatchVim
metaPatch "vim-full" $base 1 $namePatchHistory $namePatchCols $namePatchVim
metaPatch "vim-full-dev" $base 1 $namePatchHistory $namePatchCols $namePatchVim $namePatchRepaint
fi