diff options
| author | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2025-12-21 04:32:34 +0900 |
|---|---|---|
| committer | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2025-12-21 04:32:34 +0900 |
| commit | 10e4cfec4eba0ea2a4a4a169068784b5e4bfd0b9 (patch) | |
| tree | 603346e2531656305375774cf451efda709fc0d9 | |
| parent | ce6bde63e93204f76f229e7384b29a191e4d5bf6 (diff) | |
modified bin/ppts, created bin/ppts
| -rwxr-xr-x | ar/.local/bin/ppts | 99 | ||||
| -rwxr-xr-x | mac/.local/bin/ppts | 107 |
2 files changed, 186 insertions, 20 deletions
diff --git a/ar/.local/bin/ppts b/ar/.local/bin/ppts new file mode 100755 index 0000000..387bcf7 --- /dev/null +++ b/ar/.local/bin/ppts @@ -0,0 +1,99 @@ +#!/bin/sh + +# Auto workflow script for git push with content/ directory handling +# Usage: ppts +# Automatically: git add ., commit without content/, push to origin, then add content/ and push to home + +# Always cd to THESIAH repository +THESIAH_REPO="${THESIAH_WWW:-${HOME}/Private/repos/THESIAH}" + +if [ ! -d "$THESIAH_REPO" ]; then + echo "Error: THESIAH repository not found at $THESIAH_REPO" + exit 1 +fi +cd "$THESIAH_REPO" || exit 1 + +# Verify this is the correct git repository +if ! git rev-parse --git-dir >/dev/null 2>&1; then + echo "Error: Not a git repository at $THESIAH_REPO" + exit 1 +fi + +# If no arguments, run auto workflow +if [ -z "$1" ]; then + echo "Running auto workflow..." + + # Step 0: Stage all changes first + echo "Step 0: Staging all changes..." + git add . + + # Check if there are any changes to commit + if git diff --quiet && git diff --cached --quiet; then + echo "No changes to commit" + exit 0 + fi + + # Step 1: Unstage content/ from staging + echo "Step 1: Excluding content/ from staging..." + git reset content/ 2>/dev/null || true + + # Check if there are changes to commit (excluding content/) + has_changes_without_content=false + if ! git diff --cached --quiet; then + has_changes_without_content=true + fi + + # Check if content/ has changes + has_content_changes=false + if [ -d "content/" ]; then + # Check for untracked files in content/ + if [ -n "$(git ls-files --others --exclude-standard content/ 2>/dev/null)" ]; then + has_content_changes=true + fi + # Check for modified tracked files in content/ + if ! git diff --quiet content/ 2>/dev/null; then + has_content_changes=true + fi + # Check for staged changes in content/ + if ! git diff --cached --quiet content/ 2>/dev/null; then + has_content_changes=true + fi + fi + + # Step 2: Commit without content/ if there are changes + if [ "$has_changes_without_content" = true ]; then + echo "Step 2: Committing changes (without content/)..." + git commit -m "Update (without content/)" || exit 1 + + # Step 3: Push to origin (without content/) + echo "Step 3: Pushing to origin (without content/)..." + git push origin master || exit 1 + echo "✓ Pushed to origin (without content/)" + else + echo "No changes to commit (excluding content/)" + fi + + # Step 4: Add and commit content/ if there are changes + if [ "$has_content_changes" = true ]; then + echo "Step 4: Adding content/..." + git add content/ + + echo "Step 5: Committing content/..." + git commit -m "Update content/" || exit 1 + + # Step 6: Push to home (with content/)" + echo "Step 6: Pushing to home (with content/)..." + git push home master || exit 1 + echo "✓ Pushed to home (with content/)" + else + echo "No content/ changes to commit" + fi + + echo "Auto workflow completed!" + exit 0 +fi + +# If arguments provided, show usage +echo "Usage: ppts" +echo " Run without arguments to execute auto workflow" +exit 1 diff --git a/mac/.local/bin/ppts b/mac/.local/bin/ppts index bde60df..387bcf7 100755 --- a/mac/.local/bin/ppts +++ b/mac/.local/bin/ppts @@ -1,32 +1,99 @@ #!/bin/sh -# Wrapper script for git push that handles content/ directory exclusion -# Usage: ppts <remote> <branch> [other git push options] +# Auto workflow script for git push with content/ directory handling +# Usage: ppts +# Automatically: git add ., commit without content/, push to origin, then add content/ and push to home -remote="$1" -shift +# Always cd to THESIAH repository +THESIAH_REPO="${THESIAH_WWW:-${HOME}/Private/repos/THESIAH}" -# Run git push -git push "$remote" "$@" -push_exit_code=$? +if [ ! -d "$THESIAH_REPO" ]; then + echo "Error: THESIAH repository not found at $THESIAH_REPO" + exit 1 +fi +cd "$THESIAH_REPO" || exit 1 + +# Verify this is the correct git repository +if ! git rev-parse --git-dir >/dev/null 2>&1; then + echo "Error: Not a git repository at $THESIAH_REPO" + exit 1 +fi -# If push was successful and we pushed to origin, restore content/ -if [ "$push_exit_code" -eq 0 ] && [ "$remote" = "origin" ]; then - if [ -f .git/hooks/.pre-push-state ]; then - echo "Restoring content/ directory..." +# If no arguments, run auto workflow +if [ -z "$1" ]; then + echo "Running auto workflow..." - # Read the stored HEAD and temp commit - original_head=$(head -n 1 .git/hooks/.pre-push-state) + # Step 0: Stage all changes first + echo "Step 0: Staging all changes..." + git add . + + # Check if there are any changes to commit + if git diff --quiet && git diff --cached --quiet; then + echo "No changes to commit" + exit 0 + fi - # Reset to original HEAD (this will restore content/) - if [ -n "$original_head" ] && git rev-parse --verify "$original_head" >/dev/null 2>&1; then - git reset --soft "$original_head" >/dev/null 2>&1 - echo "content/ directory restored to git index" + # Step 1: Unstage content/ from staging + echo "Step 1: Excluding content/ from staging..." + git reset content/ 2>/dev/null || true + + # Check if there are changes to commit (excluding content/) + has_changes_without_content=false + if ! git diff --cached --quiet; then + has_changes_without_content=true + fi + + # Check if content/ has changes + has_content_changes=false + if [ -d "content/" ]; then + # Check for untracked files in content/ + if [ -n "$(git ls-files --others --exclude-standard content/ 2>/dev/null)" ]; then + has_content_changes=true + fi + # Check for modified tracked files in content/ + if ! git diff --quiet content/ 2>/dev/null; then + has_content_changes=true fi + # Check for staged changes in content/ + if ! git diff --cached --quiet content/ 2>/dev/null; then + has_content_changes=true + fi + fi + + # Step 2: Commit without content/ if there are changes + if [ "$has_changes_without_content" = true ]; then + echo "Step 2: Committing changes (without content/)..." + git commit -m "Update (without content/)" || exit 1 + + # Step 3: Push to origin (without content/) + echo "Step 3: Pushing to origin (without content/)..." + git push origin master || exit 1 + echo "✓ Pushed to origin (without content/)" + else + echo "No changes to commit (excluding content/)" + fi + + # Step 4: Add and commit content/ if there are changes + if [ "$has_content_changes" = true ]; then + echo "Step 4: Adding content/..." + git add content/ - # Clean up state file - rm -f .git/hooks/.pre-push-state + echo "Step 5: Committing content/..." + git commit -m "Update content/" || exit 1 + + # Step 6: Push to home (with content/)" + echo "Step 6: Pushing to home (with content/)..." + git push home master || exit 1 + echo "✓ Pushed to home (with content/)" + else + echo "No content/ changes to commit" fi + + echo "Auto workflow completed!" + exit 0 fi -exit "$push_exit_code" +# If arguments provided, show usage +echo "Usage: ppts" +echo " Run without arguments to execute auto workflow" +exit 1 |
