From 5b3c887b41ca515a524fa56a79bee28d68e40d5c Mon Sep 17 00:00:00 2001 From: Geoffrey Preud'homme Date: Thu, 25 Jan 2024 13:03:30 +0100 Subject: [PATCH] git-sync: Only push when there's something to push --- hm/git/default.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hm/git/default.nix b/hm/git/default.nix index 36b8acf..8ffcc66 100644 --- a/hm/git/default.nix +++ b/hm/git/default.nix @@ -14,9 +14,10 @@ else ( cd "${r.path}" - ${pkgs.git}/bin/git diff --quiet || echo "Repository is dirty!" + ${pkgs.git}/bin/git --no-optional-locks diff --quiet || echo "Repository is dirty!" ${pkgs.git}/bin/git pull || true - ${pkgs.git}/bin/git push || true + # Only push if there's something to push. Also prevents from trying to push on repos where we don't have rights. + (${pkgs.git}/bin/git --no-optional-locks status --porcelain -b --ignore-submodules | grep ' \[ahead [0-9]\+\]' && ${pkgs.git}/bin/git push) || true ) fi '')