49 lines
1.0 KiB
Nix
49 lines
1.0 KiB
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 .
|
|
;;
|
|
'';
|
|
}
|