aboutsummaryrefslogtreecommitdiffstats
path: root/modules/office
diff options
context:
space:
mode:
authorArpit Chakladar <arpitchakladar+git@gmail.com>2026-09-02 17:01:45 +0530
committerArpit Chakladar <arpitchakladar+git@gmail.com>2026-09-02 17:01:45 +0530
commit894f96eb131427041c2bb726b7b798edf4f683dc (patch)
tree16261d0330dd0fda1199c8ee2e6680da9d73ddd6 /modules/office
parentd058d9127f43d7c5cfdd0481b97e9fb18dc16eb8 (diff)
downloadhome-manager-config-894f96eb131427041c2bb726b7b798edf4f683dc.tar.gz
home-manager-config-894f96eb131427041c2bb726b7b798edf4f683dc.zip
feat(office/calcurse): added timeout for remote syncing
- git pull and git pull are now set to timeout at 8s, this is to ensure that it works even in offline environments
Diffstat (limited to 'modules/office')
-rw-r--r--modules/office/calcurse/calcurse-sync.sh25
1 files changed, 19 insertions, 6 deletions
diff --git a/modules/office/calcurse/calcurse-sync.sh b/modules/office/calcurse/calcurse-sync.sh
index 169adc9..8323bff 100644
--- a/modules/office/calcurse/calcurse-sync.sh
+++ b/modules/office/calcurse/calcurse-sync.sh
@@ -25,6 +25,7 @@ set -euo pipefail
DATA_DIR="${CALCURSE_DATA_DIR:-${XDG_DATA_HOME:-$HOME/.local/share}/calcurse}"
BRANCH="main"
+SYNC_TIMEOUT="8" # seconds before a network op gives up
info() { printf '\033[1;34m==>\033[0m %s\n' "$*"; }
warn() { printf '\033[1;33m==> warning:\033[0m %s\n' "$*" >&2; }
@@ -188,15 +189,20 @@ cmd_sync() {
info "Pushing to remote..."
if has_upstream; then
- push_cmd=(git push)
+ push_cmd=(timeout "$SYNC_TIMEOUT" git push)
else
- push_cmd=(git push -u origin "$BRANCH")
+ push_cmd=(timeout "$SYNC_TIMEOUT" git push -u origin "$BRANCH")
fi
if "${push_cmd[@]}"; then
info "Sync complete."
else
status=$?
+ if [ "$status" -eq 124 ]; then
+ warn "Push timed out after ${SYNC_TIMEOUT}s — commit saved locally, will"
+ warn "retry on next sync."
+ return 0
+ fi
error "Push failed."
error "This usually means the remote has commits you don't have locally"
error "(e.g. synced from another machine). Run 'calcurse-sync pull'"
@@ -212,8 +218,8 @@ cmd_pull() {
require_repo
if ! has_remote; then
- die "no remote configured for this repo.
-Run 'calcurse-sync remote <url>' first."
+ warn "no remote configured for this repo — skipping pull."
+ return 0
fi
cd "$DATA_DIR"
@@ -224,10 +230,17 @@ Run 'calcurse-sync remote <url>' first."
die "aborting pull to avoid data loss."
fi
- info "Pulling from remote..."
- if git pull --rebase origin "$BRANCH"; then
+ info "Pulling from remote (timeout ${SYNC_TIMEOUT}s)..."
+ if timeout "$SYNC_TIMEOUT" git pull --rebase origin "$BRANCH"; then
info "Up to date."
else
+ status=$?
+ if [ "$status" -eq 124 ]; then
+ warn "Pull timed out after ${SYNC_TIMEOUT}s — continuing with local data."
+ warn "Set \$CALCURSE_SYNC_TIMEOUT to a higher value if your connection"
+ warn "is just slow, not down."
+ return 0
+ fi
error "Pull failed — likely a merge conflict."
error "Resolve conflicts manually in $DATA_DIR, then run:"
error " git -C \"$DATA_DIR\" rebase --continue"