Improve gp script: fix autocomplete and enhance change detection logic
All checks were successful
Build-Test-Publish / build (linux/amd64) (push) Successful in 24s
Build-Test-Publish / build (linux/arm64) (push) Successful in 25s
Build-Test-Publish / test-install-from-scratch (linux/amd64) (push) Successful in 7s
Build-Test-Publish / test-install-from-scratch (linux/arm64) (push) Successful in 8s
All checks were successful
Build-Test-Publish / build (linux/amd64) (push) Successful in 24s
Build-Test-Publish / build (linux/arm64) (push) Successful in 25s
Build-Test-Publish / test-install-from-scratch (linux/amd64) (push) Successful in 7s
Build-Test-Publish / test-install-from-scratch (linux/arm64) (push) Successful in 8s
This commit is contained in:
parent
6a268cc6de
commit
055c00fa04
19
gp/gp
19
gp/gp
@ -131,10 +131,25 @@ check_git_repo() {
|
||||
|
||||
# Function to check for uncommitted changes
|
||||
check_for_changes() {
|
||||
if git diff --cached --quiet && git diff --quiet; then
|
||||
if [ "$ADD_ALL" = false ]; then
|
||||
local has_staged=$(! git diff --cached --quiet && echo "true" || echo "false")
|
||||
local has_modified=$(! git diff --quiet && echo "true" || echo "false")
|
||||
local has_untracked=$([ -n "$(git ls-files --others --exclude-standard)" ] && echo "true" || echo "false")
|
||||
|
||||
# If add-all is enabled, check if we have any changes at all
|
||||
if [ "$ADD_ALL" = true ]; then
|
||||
if [ "$has_staged" = false ] && [ "$has_modified" = false ] && [ "$has_untracked" = false ]; then
|
||||
print_info "No changes to commit (working tree clean)"
|
||||
exit 0
|
||||
fi
|
||||
else
|
||||
# If add-all is disabled, only check staged changes
|
||||
if [ "$has_staged" = false ]; then
|
||||
if [ "$has_modified" = true ] || [ "$has_untracked" = true ]; then
|
||||
print_warning "No staged changes found"
|
||||
print_info "Use 'gp -a' to add all files, or stage changes first with 'git add'"
|
||||
else
|
||||
print_info "No changes to commit (working tree clean)"
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
Loading…
x
Reference in New Issue
Block a user