-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate-main.sh
executable file
·57 lines (46 loc) · 1.11 KB
/
update-main.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
#!/usr/bin/env bash
set -e
IMMUS=""
_stash_arch_packs() {
git update-index --no-assume-unchanged _arch/package* misc/.config/mc/ini
git stash || true
}
_unchange_arch_packs() {
git update-index --assume-unchanged _arch/package* misc/.config/mc/ini
}
_restore_immus() {
test -z "$IMMUS" && return
while IFS= read -r line; do
test -n "$line" && sudo chattr +i "$line"
done <<< "$IMMUS"
}
_rebase_pre() {
_stash_arch_packs
IMMUS="$(lsattr -laR . 2>/dev/null | grep Immutable | sed -e 's#\s*Immutable$##g')"
test -z "$IMMUS" && return
while IFS= read -r line; do
test -n "$line" && sudo chattr -i "$line"
done <<< "$IMMUS"
}
_rebase_post() {
_unchange_arch_packs
_restore_immus
}
rebase() {
_rebase_pre
# move current host customizations as the last commit
GIT_SEQUENCE_EDITOR=./bin/git-local-last git rebase -i main || _restore_immus
_rebase_post
}
push_main() {
# move local main one behind
git branch -f main HEAD~1
# update origin
git push origin main:main $*
}
if [[ "$@" != "" ]]; then
$@
else
rebase
push_main
fi