Skip to content

Conversation

@pan93412
Copy link
Member

@pan93412 pan93412 commented Jan 28, 2026

Summary

Implements .zeaburignore file 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)

  • Add .zeaburignore file support with priority over .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 "is a directory" errors
  • Add proper directory matching with trailing slash for gitignore patterns

Tests (internal/util/pack_test.go)

  • 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

Use Cases

This feature is particularly useful when:

  • You have symlinked directories (e.g., from npx skills add) that should only exist locally
  • You want different ignore rules for deployment vs. version control
  • You need to include files that are in .gitignore but required for deployment

Example

# .zeaburignore
.agent/
.agents/
.cursor/
.codex/

Testing

All tests pass:

go test ./internal/util/... -v

Fixes #161

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Support for a prioritized ignore file (.zeaburignore) that takes precedence over .gitignore during packaging.
  • Bug Fixes

    • Improved directory traversal: skips symlinks and inaccessible paths, normalizes paths for ignore checks, and explicitly excludes .git directory contents to prevent packaging errors.
  • Tests

    • Added unit tests validating zip packaging inclusion/exclusion behavior with and without the prioritized ignore file.

✏️ Tip: You can customize this high-level summary in your review settings.

pan93412 and others added 2 commits January 28, 2026 19:38
- 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>
@pan93412 pan93412 self-assigned this Jan 28, 2026
@coderabbitai
Copy link

coderabbitai bot commented Jan 28, 2026

Walkthrough

Loads .zeaburignore with fallback to .gitignore, applies ignore patterns (normalizing paths, trailing slash for dirs) during directory walk, skips symlinks and the .git directory, improves path-access error handling by skipping problematic paths, and adds unit tests validating zip contents and ignore precedence.

Changes

Cohort / File(s) Summary
Ignore loading & traversal
internal/util/pack.go
Attempt to load .zeaburignore first, fallback to .gitignore; evaluate ignore patterns on normalized forward-slashed paths and append trailing slash for directories; skip matched files and directories (return SkipDir for dirs); explicitly skip .git directory and symlinks; on path access errors, skip instead of aborting; integrate this into existing zip packing/walk logic.
ZIP packaging tests
internal/util/pack_test.go
Add tests for PackZipWithoutGitIgnoreFiles covering cases with .zeaburignore (precedence over .gitignore, exclusions/inclusions, .git exclusion) and without .zeaburignore (use .gitignore); validate zip contents via archive/zip.
Manifest update
.../manifest_file
Lines added/modified reflecting new code and tests (+51/-7 in pack.go area; +190/-0 overall).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add .zeaburignore support for deployment filtering' accurately and concisely describes the main change: adding .zeaburignore support for filtering files during deployment packing.
Linked Issues check ✅ Passed The PR successfully implements .zeaburignore support with .gitignore fallback, symlink handling, proper path normalization, and .git directory filtering—meeting all coding requirements from issue #161.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing .zeaburignore support and addressing symlink/path handling issues—no out-of-scope modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch pan93412/zea-8670-add-zeaburignore-ignore-flag-to-deploy-command

Comment @coderabbitai help to get the list of available commands and usage tips.

@pan93412 pan93412 changed the title feat: Add .zeaburignore support for deployment filtering feat: add .zeaburignore support for deployment filtering Jan 28, 2026
- 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>
@pan93412 pan93412 force-pushed the pan93412/zea-8670-add-zeaburignore-ignore-flag-to-deploy-command branch from 188ddcc to 8ff09a5 Compare January 28, 2026 11:45
@pan93412 pan93412 marked this pull request as ready for review January 28, 2026 11:46
Copilot AI review requested due to automatic review settings January 28, 2026 11:46
Copy link

@coderabbitai coderabbitai bot left a 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.Walk encounters a symlink, info.Mode() reflects the symlink itself (not the target) since it uses os.Lstat. A symlink has ModeSymlink set but not ModeDir, so info.IsDir() will always return false for 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 .git directory is created in the test, so lines 109-114 never actually exercise the .git exclusion 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
}

Copy link

Copilot AI left a 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 .zeaburignore support with fallback to .gitignore in the zip packing logic.
  • Refine packing filters (e.g., .git directory handling, directory pattern matching, symlink handling).
  • Add unit tests covering .zeaburignore precedence and .gitignore fallback.

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>
Copy link

@coderabbitai coderabbitai bot left a 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.

@pan93412
Copy link
Member Author

@copilot In @internal/util/pack.go around lines 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.

Copy link
Contributor

Copilot AI commented Jan 28, 2026

@pan93412 I've opened a new pull request, #163, to work on those changes. Once the pull request is ready, I'll request review from you.

Co-authored-by: pan93412 <28441561+pan93412@users.noreply.github.com>
@pan93412 pan93412 merged commit c6a0b63 into main Jan 28, 2026
5 checks passed
@pan93412 pan93412 deleted the pan93412/zea-8670-add-zeaburignore-ignore-flag-to-deploy-command branch January 28, 2026 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Add --ignore flag to deploy command

3 participants