-
Notifications
You must be signed in to change notification settings - Fork 0
chore(os): add a task to create PRs for OS sync #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -6,7 +6,6 @@ vars: | |||||||||||||||||||||||||||||||
| terraform-aws-tailscale \ | ||||||||||||||||||||||||||||||||
| terraform-aws-identity-center-users \ | ||||||||||||||||||||||||||||||||
| terraform-datadog-users \ | ||||||||||||||||||||||||||||||||
| terraform-github-organization \ | ||||||||||||||||||||||||||||||||
| terraform-github-teams \ | ||||||||||||||||||||||||||||||||
| terraform-googleworkspace-users-groups-automation \ | ||||||||||||||||||||||||||||||||
| terraform-postgres-config-dbs-users-roles \ | ||||||||||||||||||||||||||||||||
|
|
@@ -15,9 +14,33 @@ vars: | |||||||||||||||||||||||||||||||
| terraform-spacelift-aws-integrations \ | ||||||||||||||||||||||||||||||||
| terraform-spacelift-events-collector-audit-trail \ | ||||||||||||||||||||||||||||||||
| terraform-spacelift-policies | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # Configuration constants | ||||||||||||||||||||||||||||||||
| SYNC_BRANCH: chore/sync-with-template | ||||||||||||||||||||||||||||||||
| SHARED_TMP_DIR: .tmp-template-sync | ||||||||||||||||||||||||||||||||
| TEMPLATE_REPO: https://github.com/masterpointio/terraform-module-template.git | ||||||||||||||||||||||||||||||||
| TEMPLATE_OWNER: masterpointio | ||||||||||||||||||||||||||||||||
| SYNC_MESSAGE: "chore: sync with latest template state" | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # Files to synchronize | ||||||||||||||||||||||||||||||||
| SYNC_FILES: >- | ||||||||||||||||||||||||||||||||
| .checkov.yaml | ||||||||||||||||||||||||||||||||
| .coderabbit.yaml | ||||||||||||||||||||||||||||||||
| .editorconfig | ||||||||||||||||||||||||||||||||
| .gitignore | ||||||||||||||||||||||||||||||||
| .github | ||||||||||||||||||||||||||||||||
| .markdownlint.yaml | ||||||||||||||||||||||||||||||||
| .terraform-docs.yaml | ||||||||||||||||||||||||||||||||
| .tflint.hcl | ||||||||||||||||||||||||||||||||
| .trunk | ||||||||||||||||||||||||||||||||
| .yamllint.yaml | ||||||||||||||||||||||||||||||||
| LICENSE | ||||||||||||||||||||||||||||||||
| aqua.yaml | ||||||||||||||||||||||||||||||||
| tasks: | ||||||||||||||||||||||||||||||||
| # ============================================================================ | ||||||||||||||||||||||||||||||||
| # File Synchronization Tasks | ||||||||||||||||||||||||||||||||
| # ============================================================================ | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| sync: | ||||||||||||||||||||||||||||||||
| desc: | | ||||||||||||||||||||||||||||||||
| Sync files from `terraform-module-template` to specified Terraform open-source module repos. | ||||||||||||||||||||||||||||||||
|
|
@@ -32,33 +55,24 @@ tasks: | |||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| vars: | ||||||||||||||||||||||||||||||||
| MODULES: "{{if .CLI_ARGS}}{{.CLI_ARGS}}{{else}}{{.DEFAULT_MODULES}}{{end}}" | ||||||||||||||||||||||||||||||||
| FILES: >- | ||||||||||||||||||||||||||||||||
| .checkov.yaml | ||||||||||||||||||||||||||||||||
| .coderabbit.yaml | ||||||||||||||||||||||||||||||||
| .editorconfig | ||||||||||||||||||||||||||||||||
| .gitignore | ||||||||||||||||||||||||||||||||
| .github | ||||||||||||||||||||||||||||||||
| .markdownlint.yaml | ||||||||||||||||||||||||||||||||
| .terraform-docs.yaml | ||||||||||||||||||||||||||||||||
| .tflint.hcl | ||||||||||||||||||||||||||||||||
| .trunk | ||||||||||||||||||||||||||||||||
| .yamllint.yaml | ||||||||||||||||||||||||||||||||
| LICENSE | ||||||||||||||||||||||||||||||||
| aqua.yaml | ||||||||||||||||||||||||||||||||
| cmds: | ||||||||||||||||||||||||||||||||
| - | | ||||||||||||||||||||||||||||||||
| # Convert newlines to spaces and remove backslashes | ||||||||||||||||||||||||||||||||
| modules=$(echo "{{.MODULES}}" | tr '\n' ' ' | sed 's/\\//g') | ||||||||||||||||||||||||||||||||
| for module in $modules | ||||||||||||||||||||||||||||||||
| do | ||||||||||||||||||||||||||||||||
| echo "Syncing files to ../$module ..." | ||||||||||||||||||||||||||||||||
| for file in {{.FILES}} | ||||||||||||||||||||||||||||||||
| for file in {{.SYNC_FILES}} | ||||||||||||||||||||||||||||||||
| do | ||||||||||||||||||||||||||||||||
| echo " Syncing $file" | ||||||||||||||||||||||||||||||||
| rsync -av --delete {{.SHARED_TMP_DIR}}/$file ../$module/ | ||||||||||||||||||||||||||||||||
| done | ||||||||||||||||||||||||||||||||
| done | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # ============================================================================ | ||||||||||||||||||||||||||||||||
| # Git Branch Management Tasks | ||||||||||||||||||||||||||||||||
| # ============================================================================ | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| pull-and-branch: | ||||||||||||||||||||||||||||||||
| desc: | | ||||||||||||||||||||||||||||||||
| Pull main branch and create a sync branch for specified Terraform open-source module repos. | ||||||||||||||||||||||||||||||||
|
|
@@ -82,7 +96,7 @@ tasks: | |||||||||||||||||||||||||||||||
| echo -e "\n\n🚀 Processing ---------------- $module \n" | ||||||||||||||||||||||||||||||||
| if [ ! -d ../$module ]; then | ||||||||||||||||||||||||||||||||
| echo "🧲 Cloning repository..." | ||||||||||||||||||||||||||||||||
| git clone "git@github.com:masterpointio/$module.git" ../$module | ||||||||||||||||||||||||||||||||
| git clone "git@github.com:{{.TEMPLATE_OWNER}}/$module.git" ../$module | ||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||
| cd ../$module | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
|
@@ -94,7 +108,15 @@ tasks: | |||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # If branch exists and delete option is turned off - skip creation | ||||||||||||||||||||||||||||||||
| if git branch --list "{{.SYNC_BRANCH}}" | grep -q "{{.SYNC_BRANCH}}" && [ "{{.DELETE_EXISTING_SYNC_BRANCH}}" = "false" ]; then | ||||||||||||||||||||||||||||||||
| echo "⏭️ Branch {{.SYNC_BRANCH}} already exists, skipping creation." | ||||||||||||||||||||||||||||||||
| echo "⏭️ Branch {{.SYNC_BRANCH}} already exists, checking it out." | ||||||||||||||||||||||||||||||||
| git checkout {{.SYNC_BRANCH}} | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # Check if local and remote branches have diverged | ||||||||||||||||||||||||||||||||
| if git status --porcelain -b | grep -q "ahead\|behind\|diverged"; then | ||||||||||||||||||||||||||||||||
| echo "⚠️ Local and remote branches have diverged. Resetting to remote branch..." | ||||||||||||||||||||||||||||||||
| git fetch origin {{.SYNC_BRANCH}} | ||||||||||||||||||||||||||||||||
| git reset --hard origin/{{.SYNC_BRANCH}} | ||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # If branch exists and delete option is turned on - delete and create new branch | ||||||||||||||||||||||||||||||||
| elif git branch --list "{{.SYNC_BRANCH}}" | grep -q "{{.SYNC_BRANCH}}" && [ "{{.DELETE_EXISTING_SYNC_BRANCH}}" = "true" ]; then | ||||||||||||||||||||||||||||||||
|
|
@@ -110,6 +132,10 @@ tasks: | |||||||||||||||||||||||||||||||
| cd - | ||||||||||||||||||||||||||||||||
| done | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # ============================================================================ | ||||||||||||||||||||||||||||||||
| # Commit and Push Tasks | ||||||||||||||||||||||||||||||||
| # ============================================================================ | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| push: | ||||||||||||||||||||||||||||||||
| desc: | | ||||||||||||||||||||||||||||||||
| Commit and push changes with the specified commit message. | ||||||||||||||||||||||||||||||||
|
|
@@ -131,25 +157,138 @@ tasks: | |||||||||||||||||||||||||||||||
| do | ||||||||||||||||||||||||||||||||
| echo "🚀 Processing ../$module..." | ||||||||||||||||||||||||||||||||
| cd ../$module | ||||||||||||||||||||||||||||||||
| echo "📝 Committing changes..." | ||||||||||||||||||||||||||||||||
| echo "🔄 Checking out {{.SYNC_BRANCH}} branch..." | ||||||||||||||||||||||||||||||||
| git checkout {{.SYNC_BRANCH}} | ||||||||||||||||||||||||||||||||
| echo "📝 Staging changes..." | ||||||||||||||||||||||||||||||||
| git add . | ||||||||||||||||||||||||||||||||
| git commit -m "chore: update with the latest template state" | ||||||||||||||||||||||||||||||||
| echo "⬆️ Pushing changes..." | ||||||||||||||||||||||||||||||||
| git push origin {{.SYNC_BRANCH}} | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # Check if there are any changes to commit | ||||||||||||||||||||||||||||||||
| if git diff --staged --quiet; then | ||||||||||||||||||||||||||||||||
| echo "⚠️ No changes to commit in $module, skipping..." | ||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||
| echo "📝 Committing changes..." | ||||||||||||||||||||||||||||||||
| git commit -m "{{.SYNC_MESSAGE}}" | ||||||||||||||||||||||||||||||||
| echo "⬆️ Pushing changes..." | ||||||||||||||||||||||||||||||||
| git push origin {{.SYNC_BRANCH}} | ||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||
| cd - | ||||||||||||||||||||||||||||||||
| done | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # ============================================================================ | ||||||||||||||||||||||||||||||||
| # Pull Request Management Tasks | ||||||||||||||||||||||||||||||||
| # ============================================================================ | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| pr: | ||||||||||||||||||||||||||||||||
| desc: | | ||||||||||||||||||||||||||||||||
| Create pull requests for the changes pushed to SYNC_BRANCH. | ||||||||||||||||||||||||||||||||
| Example: `task os:pr -- terraform-spacelift-automation` | ||||||||||||||||||||||||||||||||
| summary: | | ||||||||||||||||||||||||||||||||
| This will create pull requests from the SYNC_BRANCH to main for each of the specified | ||||||||||||||||||||||||||||||||
| Terraform module repositories using GitHub CLI. | ||||||||||||||||||||||||||||||||
| To create PRs for specific repositories, pass their names as arguments: | ||||||||||||||||||||||||||||||||
| `task os:pr -- terraform-custom-module` | ||||||||||||||||||||||||||||||||
| or for multiple modules: `task os:pr -- "terraform-custom-module terraform-another-module"` | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| vars: | ||||||||||||||||||||||||||||||||
| MODULES: "{{if .CLI_ARGS}}{{.CLI_ARGS}}{{else}}{{.DEFAULT_MODULES}}{{end}}" | ||||||||||||||||||||||||||||||||
| cmds: | ||||||||||||||||||||||||||||||||
| - | | ||||||||||||||||||||||||||||||||
| # Get the latest commit SHA from terraform-module-template | ||||||||||||||||||||||||||||||||
| echo "🔍 Fetching latest commit SHA from terraform-module-template..." | ||||||||||||||||||||||||||||||||
| template_sha=$(git ls-remote {{.TEMPLATE_REPO}} HEAD | cut -f1) | ||||||||||||||||||||||||||||||||
| template_short_sha=$(echo $template_sha | cut -c1-7) | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # Try to get the latest tag from terraform-module-template | ||||||||||||||||||||||||||||||||
| echo "🏷️ Fetching latest tag from terraform-module-template..." | ||||||||||||||||||||||||||||||||
| template_tag=$(git ls-remote --tags --sort=-version:refname {{.TEMPLATE_REPO}} | head -n1 | sed 's/.*refs\/tags\///' | sed 's/\^{}//') | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # If no tag found, use "no tags" | ||||||||||||||||||||||||||||||||
| if [ -z "$template_tag" ]; then | ||||||||||||||||||||||||||||||||
| template_tag="no tags" | ||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| echo "📝 Template info: Tag: $template_tag, SHA: $template_short_sha" | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # Convert newlines to spaces and remove backslashes | ||||||||||||||||||||||||||||||||
| modules=$(echo "{{.MODULES}}" | tr '\n' ' ' | sed 's/\\//g') | ||||||||||||||||||||||||||||||||
| for module in $modules | ||||||||||||||||||||||||||||||||
| do | ||||||||||||||||||||||||||||||||
| echo "🚀 Creating PR for ../$module..." | ||||||||||||||||||||||||||||||||
| cd ../$module | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| current_branch=$(git branch --show-current) | ||||||||||||||||||||||||||||||||
| if [ "$current_branch" != "{{.SYNC_BRANCH}}" ]; then | ||||||||||||||||||||||||||||||||
| echo "⚠️ Warning: Not on {{.SYNC_BRANCH}} branch. Current branch: $current_branch" | ||||||||||||||||||||||||||||||||
| echo "🔄 Checking out {{.SYNC_BRANCH}}..." | ||||||||||||||||||||||||||||||||
| git checkout {{.SYNC_BRANCH}} | ||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
Comment on lines
+219
to
+225
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Branch-safety check: bail out early instead of continuing on wrong branch The current logic merely warns when the user happens to be on a different branch, then checks out - git checkout {{.SYNC_BRANCH}}
+ if ! git checkout {{.SYNC_BRANCH}}; then
+ echo "❌ Failed to switch to {{.SYNC_BRANCH}} – skipping PR for $module"
+ cd -; continue
+ fiImproves robustness across all repos. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||
| # Check if there are commits ahead of main | ||||||||||||||||||||||||||||||||
| commits_ahead=$(git rev-list --count main..{{.SYNC_BRANCH}}) | ||||||||||||||||||||||||||||||||
| if [ "$commits_ahead" -eq 0 ]; then | ||||||||||||||||||||||||||||||||
| echo "⏭️ No commits ahead of main, skipping PR creation for $module" | ||||||||||||||||||||||||||||||||
| cd - | ||||||||||||||||||||||||||||||||
| continue | ||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # Ensure remote branch exists | ||||||||||||||||||||||||||||||||
| if ! git ls-remote --heads origin {{.SYNC_BRANCH}} | grep -q {{.SYNC_BRANCH}}; then | ||||||||||||||||||||||||||||||||
| echo "📤 Remote branch doesn't exist, pushing {{.SYNC_BRANCH}} to origin..." | ||||||||||||||||||||||||||||||||
| git push origin {{.SYNC_BRANCH}} | ||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # Check if PR already exists | ||||||||||||||||||||||||||||||||
| existing_pr=$(gh pr list --head {{.SYNC_BRANCH}} --base main --json number --jq '.[0].number' 2>/dev/null || echo "") | ||||||||||||||||||||||||||||||||
| if [ -n "$existing_pr" ]; then | ||||||||||||||||||||||||||||||||
| echo "📋 PR already exists (#$existing_pr), skipping PR creation for $module" | ||||||||||||||||||||||||||||||||
| cd - | ||||||||||||||||||||||||||||||||
| continue | ||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # Create PR body with template version info | ||||||||||||||||||||||||||||||||
| echo "📋 Creating pull request..." | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # Create PR body using printf to properly handle multi-line formatting | ||||||||||||||||||||||||||||||||
| pr_body=$(printf "%s\n\n%s\n%s\n%s\n\n%s\n%s\n%s\n%s\n%s" \ | ||||||||||||||||||||||||||||||||
| "This PR syncs the repository with the latest state from [terraform-module-template]({{.TEMPLATE_REPO}})." \ | ||||||||||||||||||||||||||||||||
| "**Template Version:**" \ | ||||||||||||||||||||||||||||||||
| "- **Tag:** [$template_tag]({{.TEMPLATE_REPO}}/releases/tag/$template_tag)" \ | ||||||||||||||||||||||||||||||||
| "- **Commit SHA:** $template_short_sha" \ | ||||||||||||||||||||||||||||||||
| "**Changes include:**" \ | ||||||||||||||||||||||||||||||||
| "- Updated configuration files (.checkov.yaml, .markdownlint.yaml, etc.)" \ | ||||||||||||||||||||||||||||||||
| "- Updated GitHub workflows and templates" \ | ||||||||||||||||||||||||||||||||
| "- Updated linting and formatting configurations" \ | ||||||||||||||||||||||||||||||||
| "- Updated documentation templates") | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| gh pr create \ | ||||||||||||||||||||||||||||||||
| --title "{{.SYNC_MESSAGE}}" \ | ||||||||||||||||||||||||||||||||
| --body "$pr_body" \ | ||||||||||||||||||||||||||||||||
| --base main \ | ||||||||||||||||||||||||||||||||
| --head {{.SYNC_BRANCH}} \ | ||||||||||||||||||||||||||||||||
| --repo "{{.TEMPLATE_OWNER}}/$module" | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| cd - | ||||||||||||||||||||||||||||||||
| done | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # ============================================================================ | ||||||||||||||||||||||||||||||||
| # Template Management Tasks | ||||||||||||||||||||||||||||||||
| # ============================================================================ | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| setup-template: | ||||||||||||||||||||||||||||||||
| desc: Set up the template repository in a shared temporary directory | ||||||||||||||||||||||||||||||||
| cmds: | ||||||||||||||||||||||||||||||||
| - task: cleanup-template | ||||||||||||||||||||||||||||||||
| - git clone --depth 1 https://github.com/masterpointio/terraform-module-template.git {{.SHARED_TMP_DIR}} | ||||||||||||||||||||||||||||||||
| - git clone --depth 1 {{.TEMPLATE_REPO}} {{.SHARED_TMP_DIR}} | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| cleanup-template: | ||||||||||||||||||||||||||||||||
| desc: Clean up the shared temporary directory | ||||||||||||||||||||||||||||||||
| cmds: | ||||||||||||||||||||||||||||||||
| - rm -rf {{.SHARED_TMP_DIR}} | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # ============================================================================ | ||||||||||||||||||||||||||||||||
| # Composite Workflow Tasks | ||||||||||||||||||||||||||||||||
| # ============================================================================ | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| sync-all: | ||||||||||||||||||||||||||||||||
| desc: | | ||||||||||||||||||||||||||||||||
| Pull main branch, create a sync branch, and sync with template for specified Terraform open-source module repos. | ||||||||||||||||||||||||||||||||
|
|
@@ -171,3 +310,26 @@ tasks: | |||||||||||||||||||||||||||||||
| - task: pull-and-branch | ||||||||||||||||||||||||||||||||
| - task: sync | ||||||||||||||||||||||||||||||||
| - task: cleanup-template | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| sync-and-pr: | ||||||||||||||||||||||||||||||||
| desc: | | ||||||||||||||||||||||||||||||||
| Complete workflow: sync with template, push changes, and create pull requests. | ||||||||||||||||||||||||||||||||
| Example: `task os:sync-and-pr -- terraform-spacelift-automation` | ||||||||||||||||||||||||||||||||
| summary: | | ||||||||||||||||||||||||||||||||
| This will: | ||||||||||||||||||||||||||||||||
| 1. Pull the main branch and create a new branch named 'chore/sync-with-template' | ||||||||||||||||||||||||||||||||
| 2. Sync files from the template repository | ||||||||||||||||||||||||||||||||
| 3. Commit and push changes | ||||||||||||||||||||||||||||||||
| 4. Create pull requests for the changes | ||||||||||||||||||||||||||||||||
| for each of the default Terraform module repositories listed in DEFAULT_MODULES. | ||||||||||||||||||||||||||||||||
| To sync to a specific repository (or a custom list of repositories), pass their names as arguments: | ||||||||||||||||||||||||||||||||
| `task os:sync-and-pr -- terraform-custom-module` | ||||||||||||||||||||||||||||||||
| or for multiple modules: `task os:sync-and-pr -- "terraform-custom-module terraform-another-module"` | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| vars: | ||||||||||||||||||||||||||||||||
| MODULES: "{{if .CLI_ARGS}}{{.CLI_ARGS}}{{else}}{{.DEFAULT_MODULES}}{{end}}" | ||||||||||||||||||||||||||||||||
| DELETE_EXISTING_SYNC_BRANCH: "{{.DELETE_EXISTING_SYNC_BRANCH | default false}}" | ||||||||||||||||||||||||||||||||
| cmds: | ||||||||||||||||||||||||||||||||
| - task: sync-all | ||||||||||||||||||||||||||||||||
| - task: push | ||||||||||||||||||||||||||||||||
| - task: pr | ||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Divergence check risks clobbering local commits
git status --porcelain -bflags any “ahead/behind” state and then hard-resets to the remote, which will silently drop local commits if the branch is only ahead of origin.A safer pattern is to reset only when the branch is behind or has actually diverged:
This preserves un-pushed work while still self-healing in the “behind” scenario.
🤖 Prompt for AI Agents