test: Update 13 files
Some checks failed
Build-Test-Publish / build (linux/amd64) (push) Successful in 54s
Build-Test-Publish / test-install-from-scratch (linux/amd64) (push) Has been cancelled
Build-Test-Publish / test-install-from-scratch (linux/arm64) (push) Has been cancelled
Build-Test-Publish / build (linux/arm64) (push) Has been cancelled
Some checks failed
Build-Test-Publish / build (linux/amd64) (push) Successful in 54s
Build-Test-Publish / test-install-from-scratch (linux/amd64) (push) Has been cancelled
Build-Test-Publish / test-install-from-scratch (linux/arm64) (push) Has been cancelled
Build-Test-Publish / build (linux/arm64) (push) Has been cancelled
This commit is contained in:
@ -189,4 +189,19 @@ When creating tools for getpkg:
|
|||||||
3. The tool should support `version` and `autocomplete` subcommands
|
3. The tool should support `version` and `autocomplete` subcommands
|
||||||
4. Use `getpkg publish` to upload to the registry
|
4. Use `getpkg publish` to upload to the registry
|
||||||
|
|
||||||
|
### Testing
|
||||||
|
|
||||||
|
The test script creates all temporary files and directories in `test_temp/` to keep the main directory clean:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Run tests
|
||||||
|
./test.sh
|
||||||
|
|
||||||
|
# Clean up orphaned test files from old test runs (one-time)
|
||||||
|
bash cleanup_old_test_files.sh
|
||||||
|
|
||||||
|
# Clean up orphaned test packages from getpkg.xyz
|
||||||
|
bash cleanup_test_packages.sh
|
||||||
|
```
|
||||||
|
|
||||||
For more details, see the development documentation in each tool's directory.
|
For more details, see the development documentation in each tool's directory.
|
||||||
|
98
getpkg/cleanup_test_packages.sh
Executable file
98
getpkg/cleanup_test_packages.sh
Executable file
@ -0,0 +1,98 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Cleanup script for orphaned test packages from getpkg testing
|
||||||
|
# This script removes test packages that start with "test-" from getpkg.xyz
|
||||||
|
# Run from the getpkg directory: bash cleanup_test_packages.sh
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
GETPKG="./output/getpkg"
|
||||||
|
|
||||||
|
# Colors for output
|
||||||
|
RED='\033[0;31m'
|
||||||
|
GREEN='\033[0;32m'
|
||||||
|
YELLOW='\033[1;33m'
|
||||||
|
NC='\033[0m' # No Color
|
||||||
|
|
||||||
|
echo -e "${YELLOW}Cleaning up orphaned test packages...${NC}"
|
||||||
|
|
||||||
|
# Check if getpkg binary exists
|
||||||
|
if [ ! -f "$GETPKG" ]; then
|
||||||
|
echo -e "${RED}Error: getpkg binary not found at $GETPKG${NC}"
|
||||||
|
echo "Please run ./build.sh first to build getpkg"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if SOS_WRITE_TOKEN is set
|
||||||
|
if [ -z "${SOS_WRITE_TOKEN:-}" ]; then
|
||||||
|
echo -e "${RED}Error: SOS_WRITE_TOKEN environment variable is not set${NC}"
|
||||||
|
echo "This token is required to unpublish packages from getpkg.xyz"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Using getpkg binary: $GETPKG"
|
||||||
|
echo "SOS_WRITE_TOKEN is set (${#SOS_WRITE_TOKEN} characters)"
|
||||||
|
|
||||||
|
# Get list of all packages from /dir endpoint
|
||||||
|
echo "Fetching package list from getpkg.xyz/dir..."
|
||||||
|
DIR_RESPONSE=$(curl -s "https://getpkg.xyz/dir" 2>/dev/null || echo "")
|
||||||
|
|
||||||
|
if [ -z "$DIR_RESPONSE" ]; then
|
||||||
|
echo -e "${RED}Failed to fetch package list from server${NC}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Extract test package labeltags from JSON response
|
||||||
|
# Try with jq first, fallback to grep/sed if jq is not available
|
||||||
|
if command -v jq >/dev/null 2>&1; then
|
||||||
|
TEST_PACKAGES=$(echo "$DIR_RESPONSE" | jq -r '.entries[]?.labeltags[]? // empty' 2>/dev/null | grep "^test-" | sort -u || echo "")
|
||||||
|
else
|
||||||
|
# Fallback: extract labeltags using grep and sed (less reliable but works without jq)
|
||||||
|
TEST_PACKAGES=$(echo "$DIR_RESPONSE" | grep -o '"test-[^"]*"' | sed 's/"//g' | sort -u || echo "")
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$TEST_PACKAGES" ]; then
|
||||||
|
echo -e "${GREEN}No test packages found to clean up${NC}"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "\n${YELLOW}Found test packages to clean up:${NC}"
|
||||||
|
echo "$TEST_PACKAGES" | while read -r package; do
|
||||||
|
echo " - $package"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo -e "\n${YELLOW}Cleaning up test packages...${NC}"
|
||||||
|
|
||||||
|
CLEANED_COUNT=0
|
||||||
|
FAILED_COUNT=0
|
||||||
|
|
||||||
|
# Use process substitution to avoid subshell issues
|
||||||
|
while IFS= read -r package; do
|
||||||
|
if [ -n "$package" ]; then
|
||||||
|
echo -n "Cleaning up $package... "
|
||||||
|
|
||||||
|
# Try to unpublish the package (temporarily disable set -e)
|
||||||
|
set +e
|
||||||
|
$GETPKG unpublish "$package" >/dev/null 2>&1
|
||||||
|
UNPUBLISH_RESULT=$?
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [ $UNPUBLISH_RESULT -eq 0 ]; then
|
||||||
|
echo -e "${GREEN}OK${NC}"
|
||||||
|
((CLEANED_COUNT++))
|
||||||
|
else
|
||||||
|
echo -e "${RED}FAILED${NC}"
|
||||||
|
((FAILED_COUNT++))
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done <<< "$TEST_PACKAGES"
|
||||||
|
|
||||||
|
echo -e "\n${YELLOW}Cleanup Summary:${NC}"
|
||||||
|
echo "Packages cleaned: $CLEANED_COUNT"
|
||||||
|
echo "Failed cleanups: $FAILED_COUNT"
|
||||||
|
|
||||||
|
if [ $FAILED_COUNT -eq 0 ]; then
|
||||||
|
echo -e "${GREEN}All test packages cleaned up successfully!${NC}"
|
||||||
|
else
|
||||||
|
echo -e "${YELLOW}Some packages failed to clean up. They may need manual removal.${NC}"
|
||||||
|
fi
|
@ -1 +0,0 @@
|
|||||||
Debug content
|
|
@ -1 +0,0 @@
|
|||||||
test
|
|
@ -1,7 +0,0 @@
|
|||||||
#\!/bin/bash
|
|
||||||
if [ "$1" = "version" ]; then
|
|
||||||
echo "1.0.0"
|
|
||||||
elif [ "$1" = "autocomplete" ]; then
|
|
||||||
echo "help"
|
|
||||||
echo "version"
|
|
||||||
fi
|
|
@ -1,7 +0,0 @@
|
|||||||
#\!/bin/bash
|
|
||||||
if [ "$1" = "version" ]; then
|
|
||||||
echo "1.0.0"
|
|
||||||
elif [ "$1" = "autocomplete" ]; then
|
|
||||||
echo "help"
|
|
||||||
echo "version"
|
|
||||||
fi
|
|
@ -68,6 +68,28 @@ cleanup() {
|
|||||||
# Clean up noarch variant
|
# Clean up noarch variant
|
||||||
$GETPKG unpublish "${TEST_TOOL_NAME}-noarch:universal" 2>/dev/null || true
|
$GETPKG unpublish "${TEST_TOOL_NAME}-noarch:universal" 2>/dev/null || true
|
||||||
|
|
||||||
|
# Clean up any remaining test packages that start with "test-"
|
||||||
|
echo "Cleaning up any remaining test packages..."
|
||||||
|
DIR_RESPONSE=$(curl -s "https://getpkg.xyz/dir" 2>/dev/null || echo "")
|
||||||
|
if [ -n "$DIR_RESPONSE" ]; then
|
||||||
|
# Extract test package labeltags from JSON response
|
||||||
|
if command -v jq >/dev/null 2>&1; then
|
||||||
|
TEST_PACKAGES=$(echo "$DIR_RESPONSE" | jq -r '.entries[]?.labeltags[]? // empty' 2>/dev/null | grep "^test-" | sort -u || echo "")
|
||||||
|
else
|
||||||
|
# Fallback: extract labeltags using grep and sed
|
||||||
|
TEST_PACKAGES=$(echo "$DIR_RESPONSE" | grep -o '"test-[^"]*"' | sed 's/"//g' | sort -u || echo "")
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$TEST_PACKAGES" ]; then
|
||||||
|
echo "$TEST_PACKAGES" | while read -r package; do
|
||||||
|
if [ -n "$package" ]; then
|
||||||
|
echo " Cleaning up orphaned test package: $package"
|
||||||
|
$GETPKG unpublish "$package" 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Cleaned up test tools from getpkg.xyz"
|
echo "Cleaned up test tools from getpkg.xyz"
|
||||||
else
|
else
|
||||||
echo "Note: SOS_WRITE_TOKEN not set, cannot clean up remote test objects"
|
echo "Note: SOS_WRITE_TOKEN not set, cannot clean up remote test objects"
|
||||||
|
@ -1 +0,0 @@
|
|||||||
#!/bin/bash\necho debug
|
|
@ -1 +0,0 @@
|
|||||||
#!/bin/bash\necho debug2
|
|
@ -1 +0,0 @@
|
|||||||
#!/bin/bash\necho display test
|
|
@ -1 +0,0 @@
|
|||||||
#!/bin/bash\necho multi arch
|
|
@ -1 +0,0 @@
|
|||||||
#!/bin/bash\necho robust test
|
|
@ -1 +0,0 @@
|
|||||||
test content
|
|
72
gp/gp
72
gp/gp
@ -225,19 +225,77 @@ show_status_and_confirm() {
|
|||||||
|
|
||||||
# Show staged changes
|
# Show staged changes
|
||||||
if ! git diff --cached --quiet; then
|
if ! git diff --cached --quiet; then
|
||||||
print_info "Staged changes:"
|
local staged_modified=""
|
||||||
git diff --cached --name-only -- | while IFS= read -r line; do echo " $line"; done
|
local staged_deleted=""
|
||||||
|
local staged_added=""
|
||||||
|
|
||||||
|
# Get staged file status and categorize
|
||||||
|
while IFS=$'\t' read -r status file; do
|
||||||
|
[ -z "$status" ] && continue
|
||||||
|
case "${status:0:1}" in
|
||||||
|
A) staged_added="${staged_added}${file}\n" ;;
|
||||||
|
M) staged_modified="${staged_modified}${file}\n" ;;
|
||||||
|
D) staged_deleted="${staged_deleted}${file}\n" ;;
|
||||||
|
*) staged_modified="${staged_modified}${file}\n" ;; # Default to modified for other statuses
|
||||||
|
esac
|
||||||
|
done < <(git diff --cached --name-status)
|
||||||
|
|
||||||
|
# Show staged added files
|
||||||
|
if [ -n "$staged_added" ]; then
|
||||||
|
print_info "Staged new files:"
|
||||||
|
echo -e "$staged_added" | grep -v '^$' | while IFS= read -r line; do echo " $line"; done
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Show staged modified files
|
||||||
|
if [ -n "$staged_modified" ]; then
|
||||||
|
print_info "Staged modified files:"
|
||||||
|
echo -e "$staged_modified" | grep -v '^$' | while IFS= read -r line; do echo " $line"; done
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Show staged deleted files
|
||||||
|
if [ -n "$staged_deleted" ]; then
|
||||||
|
print_info "Staged deleted files:"
|
||||||
|
echo -e "$staged_deleted" | grep -v '^$' | while IFS= read -r line; do echo " $line"; done
|
||||||
|
fi
|
||||||
|
|
||||||
has_staged_changes=true
|
has_staged_changes=true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Show unstaged changes
|
# Show unstaged changes
|
||||||
if ! git diff --quiet; then
|
if ! git diff --quiet; then
|
||||||
if [ "$ADD_ALL" = true ]; then
|
local modified_files=""
|
||||||
print_info "Modified files (will be added):"
|
local deleted_files=""
|
||||||
else
|
|
||||||
print_info "Modified files (unstaged, will NOT be included):"
|
# Get file status and categorize
|
||||||
|
while IFS=$'\t' read -r status file; do
|
||||||
|
[ -z "$status" ] && continue
|
||||||
|
case "${status:0:1}" in
|
||||||
|
M) modified_files="${modified_files}${file}\n" ;;
|
||||||
|
D) deleted_files="${deleted_files}${file}\n" ;;
|
||||||
|
*) modified_files="${modified_files}${file}\n" ;; # Default to modified for other statuses
|
||||||
|
esac
|
||||||
|
done < <(git diff --name-status)
|
||||||
|
|
||||||
|
# Show modified files
|
||||||
|
if [ -n "$modified_files" ]; then
|
||||||
|
if [ "$ADD_ALL" = true ]; then
|
||||||
|
print_info "Modified files (will be added):"
|
||||||
|
else
|
||||||
|
print_info "Modified files (unstaged, will NOT be included):"
|
||||||
|
fi
|
||||||
|
echo -e "$modified_files" | grep -v '^$' | while IFS= read -r line; do echo " $line"; done
|
||||||
fi
|
fi
|
||||||
git diff --name-only -- | while IFS= read -r line; do echo " $line"; done
|
|
||||||
|
# Show deleted files
|
||||||
|
if [ -n "$deleted_files" ]; then
|
||||||
|
if [ "$ADD_ALL" = true ]; then
|
||||||
|
print_info "Deleted files (will be removed):"
|
||||||
|
else
|
||||||
|
print_info "Deleted files (unstaged, will NOT be included):"
|
||||||
|
fi
|
||||||
|
echo -e "$deleted_files" | grep -v '^$' | while IFS= read -r line; do echo " $line"; done
|
||||||
|
fi
|
||||||
|
|
||||||
has_unstaged_changes=true
|
has_unstaged_changes=true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
1
test_gp_1752976117
Submodule
1
test_gp_1752976117
Submodule
Submodule test_gp_1752976117 added at df17a83889
49
test_gp_deleted_files.sh
Executable file
49
test_gp_deleted_files.sh
Executable file
@ -0,0 +1,49 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Test script to verify gp properly shows deleted files as deleted
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
echo "Testing gp deleted files functionality..."
|
||||||
|
|
||||||
|
# Create a temporary test directory
|
||||||
|
TEST_DIR="test_gp_$(date +%s)"
|
||||||
|
mkdir "$TEST_DIR"
|
||||||
|
cd "$TEST_DIR"
|
||||||
|
|
||||||
|
# Initialize git repo
|
||||||
|
git init
|
||||||
|
git config user.email "test@example.com"
|
||||||
|
git config user.name "Test User"
|
||||||
|
|
||||||
|
# Create some test files
|
||||||
|
echo "content1" > file1.txt
|
||||||
|
echo "content2" > file2.txt
|
||||||
|
echo "content3" > file3.txt
|
||||||
|
mkdir test_dir
|
||||||
|
echo "test content" > test_dir/test_file.txt
|
||||||
|
|
||||||
|
# Add and commit initial files
|
||||||
|
git add .
|
||||||
|
git commit -m "Initial commit"
|
||||||
|
|
||||||
|
# Now delete some files to simulate the scenario
|
||||||
|
rm file2.txt
|
||||||
|
rm -rf test_dir
|
||||||
|
echo "modified content" > file1.txt
|
||||||
|
echo "new content" > new_file.txt
|
||||||
|
|
||||||
|
# Test the gp script with dry-run to see the output
|
||||||
|
echo ""
|
||||||
|
echo "=== Testing gp --dry-run output ==="
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Run gp with dry-run to see how it categorizes the files
|
||||||
|
../gp/gp --dry-run
|
||||||
|
|
||||||
|
# Cleanup
|
||||||
|
cd ..
|
||||||
|
rm -rf "$TEST_DIR"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "Test completed!"
|
Reference in New Issue
Block a user