Files
NixOS/modules/ncli/commands/git.nix
Cookiez 134fc441a5 - Simplified command cases by removing unnecessary semicolons.
- Improved error handling in rebuild.nix for clarity and consistency.
2026-05-29 09:29:31 +02:00

41 lines
1013 B
Nix

# ncli/commands/git.nix — commit, push, pull, status, format
lib: let
inherit (lib) project;
in {
commit_case = ''
cd "$HOME/${project}" || { echo "Error: Could not change to $HOME/${project}"; exit 1; }
if [ "$#" -lt 2 ]; then
read -p "Enter commit message: " commit_msg
else
shift
commit_msg="$*"
fi
if [ -z "$commit_msg" ]; then
echo "Error: Commit message cannot be empty" >&2
exit 1
fi
git add -A && git commit -m "$commit_msg"
'';
push_case = ''
cd "$HOME/${project}" || { echo "Error: Could not change to $HOME/${project}"; exit 1; }
git push origin $(git branch --show-current)
'';
pull_case = ''
cd "$HOME/${project}" || { echo "Error: Could not change to $HOME/${project}"; exit 1; }
git pull origin $(git branch --show-current)
'';
status_case = ''
cd "$HOME/${project}" || { echo "Error: Could not change to $HOME/${project}"; exit 1; }
git status
'';
format_case = ''
nix fmt .
'';
}