Check for unpushed changes before system shutdown
This commit is contained in:
parent
0fb702ff2a
commit
c0ec64cfc2
1 changed files with 8 additions and 0 deletions
|
@ -122,15 +122,22 @@ git-pull-from-repos() {
|
||||||
|
|
||||||
git-check-unpushed() {
|
git-check-unpushed() {
|
||||||
local start_dir="$PWD"
|
local start_dir="$PWD"
|
||||||
|
local unpushed_repos='false'
|
||||||
local git_repos=($(find ~ -name .git -type d -not -path '*/.vim/*' -and -not -path '*/.local/*' -and -not -path '*/builds/*' -exec dirname {} \;))
|
local git_repos=($(find ~ -name .git -type d -not -path '*/.vim/*' -and -not -path '*/.local/*' -and -not -path '*/builds/*' -exec dirname {} \;))
|
||||||
for repo in "${git_repos[@]}"; do
|
for repo in "${git_repos[@]}"; do
|
||||||
cd "$repo" || exit 1
|
cd "$repo" || exit 1
|
||||||
local unpushed=$(git log --pretty=format:'%h' '@{u}..' 2>/dev/null | wc -c)
|
local unpushed=$(git log --pretty=format:'%h' '@{u}..' 2>/dev/null | wc -c)
|
||||||
if [ "$unpushed" -ne 0 ]; then
|
if [ "$unpushed" -ne 0 ]; then
|
||||||
echo "Unpushed changes in $repo"
|
echo "Unpushed changes in $repo"
|
||||||
|
local unpushed_repos='true'
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
cd "$start_dir" || exit 1
|
cd "$start_dir" || exit 1
|
||||||
|
if [ "$unpushed_repos" = 'true' ]; then
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
hello() {
|
hello() {
|
||||||
|
@ -152,6 +159,7 @@ hello() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bye() {
|
bye() {
|
||||||
|
git-check-unpushed || return 1
|
||||||
if command -v protonvpn >/dev/null 2>&1; then
|
if command -v protonvpn >/dev/null 2>&1; then
|
||||||
sudo protonvpn d
|
sudo protonvpn d
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Add table
Reference in a new issue