-
Notifications
You must be signed in to change notification settings - Fork 13
feat: add .zeaburignore support for deployment filtering #162
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
feat: add .zeaburignore support for deployment filtering #162
Conversation
- Implement .zeaburignore file support for deployment filtering - .zeaburignore has higher priority than .gitignore - Fallback to .gitignore if .zeaburignore doesn't exist - Fix .git directory filtering to not exclude .gitignore file - Add proper handling for symlinks to avoid deployment errors - Add proper directory matching with trailing slash for gitignore patterns Fixes #161 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Add test for .zeaburignore taking precedence over .gitignore - Add test for fallback to .gitignore when .zeaburignore doesn't exist - Verify proper exclusion of files and directories - Verify that .gitignore file itself is included in the zip Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
WalkthroughLoads Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
- Change package name to util_test for proper test isolation - Check error return value of os.Chdir in defer statements - Replace deprecated filepath.HasPrefix with strings.HasPrefix - Add proper error handling for directory restoration Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
188ddcc to
8ff09a5
Compare
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.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@internal/util/pack_test.go`:
- Around line 103-107: The test currently logs instead of asserting presence of
"test.log": replace the t.Logf call in the pack_test.go block that checks
filesInZip["test.log"] with a failing assertion (e.g., t.Fatalf or t.Errorf
followed by return) so the test fails when "test.log" is missing; locate the
conditional that references filesInZip["test.log"] and change the t.Logf(...) to
something like t.Fatalf("expected test.log to be in zip when .zeaburignore takes
precedence") to enforce the expectation.
🧹 Nitpick comments (2)
internal/util/pack.go (1)
111-118: Dead code: symlink cannot be a directory.When
filepath.Walkencounters a symlink,info.Mode()reflects the symlink itself (not the target) since it usesos.Lstat. A symlink hasModeSymlinkset but notModeDir, soinfo.IsDir()will always returnfalsefor symlinks. The check on lines 114-116 is unreachable.🔧 Suggested simplification
// Skip symlinks to avoid "is a directory" errors if info.Mode()&os.ModeSymlink != 0 { fmt.Printf("Skipping symlink: %s\n", path) - if info.IsDir() { - return filepath.SkipDir - } return nil }internal/util/pack_test.go (1)
109-114: Consider adding test coverage for symlink handling.The PR objectives mention that symlinked directories were a key motivation (causing "is a directory" errors). However, there's no test that creates a symlink to verify it gets skipped. Additionally, no
.gitdirectory is created in the test, so lines 109-114 never actually exercise the.gitexclusion logic.You could add symlink coverage like this (platform-dependent):
// Create a symlink to test skipping targetDir := filepath.Join(tmpDir, "link_target") if err := os.MkdirAll(targetDir, 0755); err != nil { t.Fatalf("Failed to create target dir: %v", err) } symlinkPath := filepath.Join(tmpDir, "symlink_dir") if err := os.Symlink(targetDir, symlinkPath); err != nil { t.Logf("Skipping symlink test (not supported): %v", err) } else { // Verify symlink is not in zip after packing }
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.
Pull request overview
Adds deployment-time ignore rules via a new .zeaburignore file (taking precedence over .gitignore) to control what gets zipped and uploaded during zeabur deploy, addressing symlink-related packing failures.
Changes:
- Implement
.zeaburignoresupport with fallback to.gitignorein the zip packing logic. - Refine packing filters (e.g.,
.gitdirectory handling, directory pattern matching, symlink handling). - Add unit tests covering
.zeaburignoreprecedence and.gitignorefallback.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| internal/util/pack.go | Loads .zeaburignore first (fallback to .gitignore) and updates walk-time filtering logic for zipping. |
| internal/util/pack_test.go | Adds tests for ignore precedence/fallback and validates expected zip contents. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Remove verbose stdout logging that clutters CLI output - Fix test assertion for test.log to properly validate .zeaburignore precedence - Add .git/config to test fixtures to properly test .git exclusion - Add .gitignore to expected files to verify it's included in zip - Remove unused ignoreFile variable Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
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.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@internal/util/pack.go`:
- Around line 84-99: The ignore matching uses raw OS paths (backslashes on
Windows) so ignoreObject.MatchesPath fails; before calling MatchesPath in the
block that constructs checkPath (using variables path and info.IsDir()),
normalize separators to forward slashes with filepath.ToSlash(checkPath) and
then ensure the trailing "/" for directories, and pass that normalized string to
ignoreObject.MatchesPath so gitignore-style patterns match correctly across
platforms.
|
@copilot In |
Co-authored-by: pan93412 <28441561+pan93412@users.noreply.github.com>
Summary
Implements
.zeaburignorefile support to address #161. This allows users to specify files and directories to exclude during deployment, with higher priority than.gitignore.Changes
Implementation (
internal/util/pack.go).zeaburignorefile support with priority over.gitignore.gitignoreif.zeaburignoredoesn't exist.gitdirectory filtering to not exclude.gitignorefileTests (
internal/util/pack_test.go).zeaburignoretaking precedence over.gitignore.gitignorewhen.zeaburignoredoesn't exist.gitignorefile itself is included in the zipUse Cases
This feature is particularly useful when:
npx skills add) that should only exist locally.gitignorebut required for deploymentExample
Testing
All tests pass:
go test ./internal/util/... -vFixes #161
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes
Tests
✏️ Tip: You can customize this high-level summary in your review settings.