Created
March 2, 2026 21:09
-
-
Save lewislarsen/76929e48d3d20ee12408b1d3eab3e2db to your computer and use it in GitHub Desktop.
Quick bash script to fetch new commits from the Laravel Horizon upstream branch.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Cherry-pick helper script for Horizon fork | |
| # This script analyzes upstream commits and generates cherry-pick commands | |
| REPO_PATH="$HOME/Developer/packages/horizon" | |
| # Color codes for output | |
| GREEN='\033[0;32m' | |
| YELLOW='\033[1;33m' | |
| BLUE='\033[0;34m' | |
| RED='\033[0;31m' | |
| NC='\033[0m' # No Color | |
| echo -e "${BLUE}=== Horizon Cherry-Pick Helper ===${NC}\n" | |
| # Check if repo exists | |
| if [ ! -d "$REPO_PATH" ]; then | |
| echo -e "${RED}Error: Repository not found at $REPO_PATH${NC}" | |
| exit 1 | |
| fi | |
| # Change to repo directory | |
| cd "$REPO_PATH" || exit 1 | |
| echo -e "${BLUE}Working in:${NC} $REPO_PATH\n" | |
| # Get current branch | |
| CURRENT_BRANCH=$(git branch --show-current) | |
| echo -e "${GREEN}Current branch:${NC} $CURRENT_BRANCH\n" | |
| # Fetch upstream | |
| echo -e "${YELLOW}Fetching upstream...${NC}" | |
| git fetch upstream | |
| # Get list of commits in upstream but not in HEAD | |
| echo -e "\n${BLUE}Analyzing commits...${NC}\n" | |
| # Get the cherry output (+ means not in HEAD, - means already in HEAD) | |
| CHERRY_OUTPUT=$(git cherry upstream/$CURRENT_BRANCH) | |
| # Build a list of commit hashes that are NEW (marked with +) | |
| NEW_COMMIT_HASHES=$(echo "$CHERRY_OUTPUT" | grep "^+" | awk '{print $2}') | |
| # Parse and categorize commits | |
| echo -e "${GREEN}=== NEW COMMITS TO CHERRY-PICK ===${NC}\n" | |
| # Collect new commits first | |
| rm -f /tmp/horizon_new_commits.txt | |
| git log --oneline --no-decorate HEAD..upstream/$CURRENT_BRANCH --reverse --format="%H|%h|%s|%an|%ar" | while IFS='|' read -r full_hash short_hash subject author date; do | |
| # Check if this commit is marked as new by git cherry (has + prefix) | |
| if ! echo "$NEW_COMMIT_HASHES" | grep -q "^$full_hash"; then | |
| continue | |
| fi | |
| # Skip certain commit types by default (can be customized) | |
| if echo "$subject" | grep -qE "^Apply fixes from StyleCI|^Compile Assets$|^Update CHANGELOG$"; then | |
| continue | |
| fi | |
| echo -e "${GREEN}✓${NC} $short_hash | $subject | $author | $date" | |
| echo "$full_hash|$short_hash|$subject" >> /tmp/horizon_new_commits.txt | |
| done | |
| # Check if we have any new commits | |
| if [ ! -f /tmp/horizon_new_commits.txt ]; then | |
| echo -e "${GREEN}🎉 You're all caught up! No new commits to cherry-pick.${NC}\n" | |
| exit 0 | |
| fi | |
| # Generate cherry-pick commands only if we have new commits | |
| echo -e "\n${YELLOW}=== CHERRY-PICK COMMANDS ===${NC}\n" | |
| echo "cd $REPO_PATH" | |
| echo "" | |
| while IFS='|' read -r full_hash short_hash subject; do | |
| echo "git cherry-pick $short_hash # $subject" | |
| done < /tmp/horizon_new_commits.txt | |
| rm -f /tmp/horizon_new_commits.txt | |
| echo "" | |
| echo "# After cherry-picking, push to your fork:" | |
| echo "git push origin $CURRENT_BRANCH" | |
| echo -e "\n${GREEN}Done!${NC}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment