|
24 | 24 | </command> |
25 | 25 | </template> |
26 | 26 | </pattern> |
27 | | - <pattern name="resolving_conflicts_rebase"> |
28 | | - <usage>A sequence of commands to resolve merge conflicts locally using rebase.</usage> |
| 27 | + <pattern name="detecting_conflicts"> |
| 28 | + <usage>Commands to detect merge conflicts.</usage> |
| 29 | + <template> |
| 30 | + <comment>Fetch latest main branch</comment> |
| 31 | + <command tool="git">git fetch origin main</command> |
| 32 | + <comment>Check if rebase would create conflicts</comment> |
| 33 | + <command tool="git">git rebase --dry-run origin/main</command> |
| 34 | + </template> |
| 35 | + </pattern> |
| 36 | + |
| 37 | + <pattern name="non_interactive_rebase"> |
| 38 | + <usage>Rebase operations using GIT_EDITOR to prevent interactive prompts.</usage> |
29 | 39 | <template> |
30 | | - <command tool="git">git checkout main</command> |
31 | | - <command tool="git">git pull origin main</command> |
32 | 40 | <command tool="git">git checkout <pr_branch></command> |
33 | | - <command tool="git">git rebase main</command> |
34 | | - <comment>After resolving conflicts manually, continue the rebase.</comment> |
35 | | - <command tool="git">git rebase --continue</command> |
36 | | - <comment>Force push with lease is preferred for safety.</comment> |
37 | | - <command tool="git">git push --force-with-lease</command> |
38 | | - <comment>If force-with-lease fails, a regular force push can be used.</comment> |
39 | | - <command tool="git">git push --force</command> |
| 41 | + <command tool="git">GIT_EDITOR=true git rebase main</command> |
| 42 | + <comment>If conflicts occur, resolve them manually then use 'git rebase --continue'</comment> |
| 43 | + <command tool="git">git push --force-with-lease <remote> <pr_branch></command> |
| 44 | + </template> |
| 45 | + </pattern> |
| 46 | + |
| 47 | + <pattern name="conflict_status_check"> |
| 48 | + <usage>Check current conflict status without interactive input.</usage> |
| 49 | + <template> |
| 50 | + <command tool="git">git status --porcelain</command> |
| 51 | + <command tool="git">git diff --name-only --diff-filter=U</command> |
| 52 | + <comment>List files with unresolved conflicts</comment> |
| 53 | + <command tool="git">git ls-files --unmerged</command> |
40 | 54 | </template> |
41 | 55 | </pattern> |
42 | 56 | <pattern name="checking_out_pr"> |
43 | | - <usage>Command to check out a pull request branch locally.</usage> |
| 57 | + <usage>Check out a pull request branch locally.</usage> |
| 58 | + <template> |
| 59 | + <command tool="gh">gh pr checkout <pr_number_or_url> --force</command> |
| 60 | + <comment>Alternative if gh checkout fails:</comment> |
| 61 | + <command tool="git">git fetch origin pull/<pr_number>/head:<branch_name> && git checkout <branch_name></command> |
| 62 | + </template> |
| 63 | + </pattern> |
| 64 | + |
| 65 | + <pattern name="determine_push_remote"> |
| 66 | + <usage>Determine the correct remote to push to (handles forks).</usage> |
| 67 | + <template> |
| 68 | + <comment>Get PR metadata to check if it's from a fork</comment> |
| 69 | + <command tool="gh">gh pr view <pr_number> --json headRepositoryOwner,headRefName,isCrossRepository</command> |
| 70 | + <comment>If isCrossRepository is true, it's from a fork</comment> |
| 71 | + <command tool="git">git remote -v</command> |
| 72 | + <comment>Check if fork remote exists, otherwise add it</comment> |
| 73 | + <command tool="git">git remote add fork https://github.com/<fork_owner>/<repo_name>.git</command> |
| 74 | + <comment>Use appropriate remote based on PR source</comment> |
| 75 | + </template> |
| 76 | + </pattern> |
| 77 | + |
| 78 | + <pattern name="real_time_monitoring"> |
| 79 | + <usage>Monitor PR checks in real-time as they run.</usage> |
| 80 | + <template> |
| 81 | + <command tool="gh">gh pr checks <pr_number> --watch</command> |
| 82 | + <comment>Continuously monitor check status with automatic updates</comment> |
| 83 | + <alternative>For one-time status check: gh pr checks <pr_number> --json state,conclusion,name,detailsUrl</alternative> |
| 84 | + <command tool="gh">gh run list --pr <pr_number> --json databaseId,status,conclusion</command> |
| 85 | + </template> |
| 86 | + </pattern> |
| 87 | + |
| 88 | + <pattern name="safe_push_operations"> |
| 89 | + <usage>Push operations that handle both origin and fork remotes correctly.</usage> |
44 | 90 | <template> |
45 | | - <command tool="gh">gh pr checkout <pr_number_or_url></command> |
| 91 | + <comment>First determine the correct remote (origin or fork)</comment> |
| 92 | + <command tool="gh">gh pr view <pr_number> --json headRepositoryOwner,headRefName,isCrossRepository</command> |
| 93 | + <comment>If isCrossRepository is false, push to origin</comment> |
| 94 | + <command tool="git">git push --force-with-lease origin <branch_name></command> |
| 95 | + <comment>If isCrossRepository is true, push to fork remote</comment> |
| 96 | + <command tool="git">git push --force-with-lease fork <branch_name></command> |
| 97 | + <comment>If force-with-lease fails, fetch and retry</comment> |
| 98 | + <command tool="git">git fetch <remote> <branch_name></command> |
| 99 | + <command tool="git">git push --force <remote> <branch_name></command> |
46 | 100 | </template> |
47 | 101 | </pattern> |
48 | | - <pattern name="watching_pr_checks"> |
49 | | - <usage>After pushing changes, use this command to monitor the CI/CD pipeline in real-time.</usage> |
| 102 | + |
| 103 | + <pattern name="automated_commit_operations"> |
| 104 | + <usage>Commit operations that work in automated environments.</usage> |
50 | 105 | <template> |
51 | | - <command tool="gh">gh pr checks --watch</command> |
| 106 | + <command tool="git">git add .</command> |
| 107 | + <command tool="git">git commit -m "<commit_message>"</command> |
52 | 108 | </template> |
53 | 109 | </pattern> |
54 | 110 | </common_patterns> |
0 commit comments