-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
sync.sh
executable file
·46 lines (41 loc) · 1.13 KB
/
sync.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
#!/usr/bin/env bash
#
# SPDX-FileCopyrightText: © 2020-2023 Serpent OS Developers
#
# SPDX-License-Identifier: Zlib
#
# serpent-style/sync.sh syncs the git repo from which it is run to the newest
# serpent-style/ submodule and commits with the message:
#
# "serpent-style: Sync"
set -e
function failMsg ()
{
echo -e "$*"
exit 1
}
function hasSerpentStyleSubmodule ()
{
if [[ -d "${PWD}"/.git/ ]]; then
if [[ -d "${PWD}"/serpent-style/ ]]; then
return 0 # "success"
else
failMsg "\n${PWD} does not appear to have a serpent-style/ submodule?\n"
fi
else
failMsg "\n${PWD} does not appear to be a git repo?\n"
fi
}
# Should be run from within a known good git repo
function checkGitStatusClean ()
{
if [[ -z $(git status --untracked-files=no --porcelain .) ]]; then
return 0
else
failMsg "\n Git repo ${PWD} contains uncommitted changes?\n '- Aborting!\n"
fi
}
hasSerpentStyleSubmodule && checkGitStatusClean
git submodule update --remote --merge serpent-style/ && \
git add serpent-style && \
git commit -S -s -m "serpent-style: Sync"