feat(core): add .nx/polygraph to gitignore in migration and caia#34659
feat(core): add .nx/polygraph to gitignore in migration and caia#34659
Conversation
✅ Deploy Preview for nx-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for nx-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
View your CI Pipeline Execution ↗ for commit de6f232
☁️ Nx Cloud last updated this comment at |
| ig.add(gitignore); | ||
| if (!ig.ignores(entry)) { | ||
| const updatedLines = gitignore.length ? [gitignore, entry] : [entry]; | ||
| tree.write(gitignorePath, updatedLines.join('\n')); |
There was a problem hiding this comment.
Missing trailing newline in the generated .gitignore file. The current code uses join('\n') which places newlines between elements but not at the end. This removes any trailing newline that existed in the original file, violating POSIX text file standards and potentially causing git to show "no newline at end of file" warnings.
Impact: Changes file format unexpectedly, may cause git warnings.
Fix:
tree.write(gitignorePath, updatedLines.join('\n') + '\n');This ensures the file always ends with a newline, which is the standard for text files.
| tree.write(gitignorePath, updatedLines.join('\n')); | |
| tree.write(gitignorePath, updatedLines.join('\n') + '\n'); |
Spotted by Graphite
Is this helpful? React 👍 or 👎 to let us know.
This comment came from an experimental review—please leave feedback if it was helpful/unhelpful. Learn more about experimental comments here.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Free Tier Details
You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| ig.add(gitignore); | ||
| if (!ig.ignores(entry)) { | ||
| const updatedLines = gitignore.length ? [gitignore, entry] : [entry]; | ||
| tree.write(gitignorePath, updatedLines.join('\n')); |
There was a problem hiding this comment.
Written gitignore file lacks trailing newline
Low Severity
addEntryToGitIgnore writes the updated .gitignore without a trailing newline. When the existing content ends with \n (standard for text files), [gitignore, entry].join('\n') produces a double blank line before the entry and no final newline. The migration path has no Prettier pass to fix this, so git will warn about \ No newline at end of file for every user who runs this migration.
Additional Locations (1)
There was a problem hiding this comment.
Important
At least one additional CI pipeline execution has run since the conclusion below was written and it may no longer be applicable.
Nx Cloud is proposing a fix for your failed CI:
These changes fix the test failure by updating the expected output message. The new migration 22-7-0-add-polygraph-to-git-ignore legitimately modifies .gitignore in fresh workspaces, causing lerna repair to output "Successfully repaired your configuration" instead of "No changes were necessary". This test now correctly expects the new behavior introduced by the PR's migration.
Warning
❌ We could not verify this fix.
diff --git a/e2e/lerna-smoke-tests/src/lerna-smoke-tests.test.ts b/e2e/lerna-smoke-tests/src/lerna-smoke-tests.test.ts
index bdddb8842a..d02d5642d6 100644
--- a/e2e/lerna-smoke-tests/src/lerna-smoke-tests.test.ts
+++ b/e2e/lerna-smoke-tests/src/lerna-smoke-tests.test.ts
@@ -45,7 +45,7 @@ describe('Lerna Smoke Tests', () => {
.replace(/Ran .* from .*\n .*\n\n/g, '') // end of individual migration run
.replace(/No changes were made\n\n/g, ''); // no changes during individual migration run
expect(result).toContain(
- 'Lerna No changes were necessary. This workspace is up to date!'
+ 'Lerna Successfully repaired your configuration. This workspace is up to date!'
);
}, 1000000);
});
🔔 Heads up, your workspace has pending recommendations ↗ to auto-apply fixes for similar failures.
Or Apply changes locally with:
npx nx-cloud apply-locally ovtL-CV8q
Apply fix locally with your editor ↗ View interactive diff ↗
🎓 Learn more about Self-Healing CI on nx.dev
) (cherry picked from commit aa4f47e)
|
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |


Current Behavior
Expected Behavior
Related Issue(s)
Fixes #
Note
Low Risk
Low risk: additive changes that only update
.gitignoreusing an ignore-pattern check to avoid duplicates or already-covered entries; no runtime behavior beyond file generation/migrations.Overview
Ensures
.nx/polygraphis automatically ignored by Git.Adds a
22-7-0-add-polygraph-to-git-ignoremigration (registered inmigrations.json) that appends.nx/polygraphto an existing.gitignore, while skipping Lerna-only workspaces (withlerna.jsonbut nonx.json).Updates the
setup-ai-agentsgenerator to also add.nx/polygraphto the target directory’s.gitignore, and introduces a sharedaddEntryToGitIgnorehelper that avoids adding the entry when it’s already present or covered by broader ignore rules; tests were added for both the migration and generator behavior.Written by Cursor Bugbot for commit de6f232. This will update automatically on new commits. Configure here.