This repository has been archived by the owner on Sep 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.bash
executable file
·102 lines (86 loc) · 2.56 KB
/
update.bash
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
#!/usr/bin/env bash
# A script for getting configuration updates from origin
# This script can be used to update the configuration before Emacs
# starts.
# Clean the working tree
section() {
# TODO: Colourize the output
echo "$*"
}
section "Updating the Emacs configuration..."
# echo "Checking if $PWD has changes..."
# if ! git diff-index --name-status --exit-code HEAD; then
# echo "The working tree has changes. Please stash or commit them."
# echo "Entering a subshell."
# $SHELL -i
# if ! git diff-index --name-status --exit-code HEAD; then
# echo "There are still changes. Aborting." >&2
# echo "Press enter to exit"
# read -r
# exit 1
# fi
# else
# echo "No changes in the working tree."
# fi
# Rebase HEAD onto its corresponding remote branch
remote=origin
branch=$(git symbolic-ref --short HEAD)
git fetch $remote
if git --no-pager log --exit-code --oneline --summary "HEAD..$remote/$branch"; then
echo "The branch is up-to-date."
else
if ! git rebase --autostash --preserve-merges "$remote/$branch"; then
$SHELL -i
fi
# echo -n "Rebase onto $remote/$branch? (y/n): "
# read -r need_rebase
# if [[ ${need_rebase} = [Yy]* ]]; then
# if ! git rebase "$remote/$branch"; then
# echo "There was an error during the rebase."
# echo "Press enter."
# read -r
# exit 1
# fi
# fi
fi
section "Updating the submodules in the Emacs configuration..."
# Update the submodule
git submodule update --recursive
pull_all_packages_ff() {
local initial="$PWD"
local parent="$PWD/straight/repos"
cd "$parent" || return 1
for d in *; do
cd "$parent/$d" || continue
git pull --ff-only --recurse-submodules origin
done
cd "$initial" || exit 1
}
pull_package() {
local initial="$PWD"
local package="$1"
cd "straight/repos/$package" || return 1
git pull --ff-only --recurse-submodules origin
cd "$initial" || exit 1
}
echo -n "Rebuild the updated packages? (y/n): "
read -r update
if [[ ${update} = [Yy]* ]]; then
echo -n "Pull all packages? (y/n): "
read -r fetch
if [[ ${fetch} = [Yy]* ]]; then
pull_all_packages_ff
else
pull_package melpa
./update-packages.bash
fi
section "Rebuilding org autoloads..."
cd straight/repos/org
make autoloads
cd ../../..
section "Rebuilding outdated packages..."
emacs -nw -q --load init.el \
--eval '(progn (akirak/straight-rebuild-outdated-packages) (kill-emacs))'
fi
echo "Done."
exit 0