Skip to content

[CHORE] Use .gitattributes to ignore export files list#46

Merged
guibranco merged 3 commits intomainfrom
chore/use-git-attributes
Apr 24, 2026
Merged

[CHORE] Use .gitattributes to ignore export files list#46
guibranco merged 3 commits intomainfrom
chore/use-git-attributes

Conversation

@guibranco
Copy link
Copy Markdown
Owner

@guibranco guibranco commented Apr 24, 2026

📑 Description

Use .gitattributes to ignore export files list

✅ Checks

  • My pull request adheres to the code style of this project
  • My code requires changes to the documentation
  • I have updated the documentation as required
  • All the tests have passed

☢️ Does this introduce a breaking change?

  • Yes
  • No

Summary by Sourcery

Use Git archive-based packaging controlled by .gitattributes for plugin staging and release artifacts.

Build:

  • Introduce .gitattributes to define which files are included or excluded from exported plugin packages.

CI:

  • Replace rsync-based staging in test workflow with git archive to rely on repository export configuration.
  • Update release workflow to build the distributable ZIP directly from git archive instead of manual rsync and zip steps.

Summary by CodeRabbit

  • Chores
    • Streamlined release and testing workflows by adopting git archive for package generation, improving consistency and ensuring unnecessary files are automatically excluded from distributions.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Apr 24, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Refactors the release and test workflows to use Git’s archive mechanism (driven by .gitattributes) instead of rsync-based exclusion lists for building/staging the plugin artifacts.

Flow diagram for plugin packaging before and after git archive change

flowchart LR
  subgraph Before_change_rsync_based
    A[Checkout repository] --> B[Create /tmp/ipquery directory]
    B --> C[Run rsync with many --exclude patterns]
    C --> D[Staged plugin tree in /tmp/ipquery]
    D --> E[zip -r ipquery-VERSION.zip ipquery/]
    E --> F[Upload/use ZIP artifact]
  end

  subgraph After_change_git_archive_based
    A2[Checkout repository] --> B2[Run git archive HEAD]
    B2 --> C2[.gitattributes controls exported files]
    C2 --> D2[Extract archive to /tmp/ipquery or write ZIP directly]
    D2 --> E2[ipquery-VERSION.zip from git archive]
    E2 --> F2[Upload/use ZIP artifact]
  end

  style Before_change_rsync_based fill:#f9f9f9,stroke:#bbb
  style After_change_git_archive_based fill:#f9f9f9,stroke:#bbb
Loading

File-Level Changes

Change Details Files
Replace rsync-based file staging in CI with git archive driven by .gitattributes for both release and test workflows.
  • In the release workflow, stage the plugin into /tmp/ipquery using `git archive HEAD
tar -x -C /tmp/ipqueryinstead of rsync with an explicit exclude list.</li><li>In the release workflow packaging step, generate the distributable zip usinggit archive HEAD --prefix=ipquery/ --output="/tmp/ipquery-${VERSION}.zip"instead of creating the directory and zipping it manually.</li><li>In the test workflow, stage the plugin into /tmp/ipquery usinggit archive HEAD
Introduce a .gitattributes file to define which files are included or excluded from git archive, centralizing the export-ignore configuration.
  • Add a new .gitattributes file that encodes the export-ignore rules previously duplicated in the workflow rsync exclude lists so that archives only contain the desired distributable files.
.gitattributes

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@guibranco guibranco enabled auto-merge (squash) April 24, 2026 10:27
@gstraccini gstraccini Bot added the ☑️ auto-merge Automatic merging of pull requests (gstraccini-bot) label Apr 24, 2026
Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • Since git archive now controls what goes into the plugin package, double‑check that .gitattributes marks all previously rsync-excluded paths (e.g. .github, tests, docs, build/config files) with export-ignore so the resulting archive matches the old contents.
  • git archive HEAD only includes committed files, whereas the previous rsync approach would pick up uncommitted build artifacts; if your release process relies on generated files, consider adding an explicit build step that commits or stages them, or document that releases must be created from clean commits.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Since `git archive` now controls what goes into the plugin package, double‑check that `.gitattributes` marks all previously `rsync`-excluded paths (e.g. `.github`, `tests`, `docs`, build/config files) with `export-ignore` so the resulting archive matches the old contents.
- `git archive HEAD` only includes committed files, whereas the previous `rsync` approach would pick up uncommitted build artifacts; if your release process relies on generated files, consider adding an explicit build step that commits or stages them, or document that releases must be created from clean commits.

## Individual Comments

### Comment 1
<location path=".github/workflows/release.yml" line_range="144" />
<code_context>
-            ./ /tmp/ipquery/
-          cd /tmp
-          zip -r "ipquery-${VERSION}.zip" ipquery/
+          git archive HEAD --prefix=ipquery/ --output="/tmp/ipquery-${VERSION}.zip"
           echo "ZIP=/tmp/ipquery-${VERSION}.zip" >> "$GITHUB_ENV"

</code_context>
<issue_to_address>
**issue (bug_risk):** The `git archive` output is likely a tar stream despite the `.zip` extension; consider explicitly setting `--format=zip`.

This mismatch will likely break any consumer expecting a real zip file. You can align the content with the extension by using:

git archive --format=zip HEAD --prefix=ipquery/ --output="/tmp/ipquery-${VERSION}.zip"
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread .github/workflows/release.yml Outdated
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 24, 2026

Warning

Rate limit exceeded

@guibranco has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 52 minutes and 8 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 52 minutes and 8 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6f9fd4c7-aa03-4eb9-af16-72322b513caf

📥 Commits

Reviewing files that changed from the base of the PR and between 71fe3e7 and a13738e.

📒 Files selected for processing (1)
  • .github/workflows/release.yml

Walkthrough

The changes transition from filesystem-based rsync with explicit exclusions to a VCS-based packaging approach using git archive with .gitattributes configuration. A new .gitattributes file marks files for export-ignore, while GitHub workflows are updated to use git archive instead of rsync for packaging and staging.

Changes

Cohort / File(s) Summary
Git Attributes Configuration
.gitattributes
New configuration file setting export-ignore for curated files and directories to be omitted from archive exports.
Workflow Packaging Updates
.github/workflows/release.yml, .github/workflows/test.yml
Both workflows replaced filesystem-based rsync exclusion patterns with VCS-based git archive extraction, streamlining the staging and packaging steps for plugin builds.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 Archive via git, oh what a treat!
No more rsync with patterns to repeat,
Git attributes mark what to ignore,
Cleaner workflows than ever before!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: introducing .gitattributes to manage export file exclusions, which is the central objective across all modified files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/use-git-attributes

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 24, 2026

✅ WordPress Plugin Check Report

✅ Status: Passed

📊 Report

All checks passed! No errors or warnings found.


🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check

Copy link
Copy Markdown

@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.

🧹 Nitpick comments (1)
.gitattributes (1)

1-18: LGTM — solid export-ignore list.

Leading-slash anchoring is correct, directory entries are properly trailing-slashed, and /vendor/ vs. includes/vendor/ will work as intended. Keeping readme.txt while excluding /README.md is the right call for WP.org packaging.

One optional thought: if the repo ever grows any of these top-level dev/config files, consider adding them here as well so they never leak into the zip:

  • /.editorconfig, /.prettierrc*, /.eslintrc*
  • /package.json, /package-lock.json, /node_modules/
  • /.phpcs.xml.dist (in case a dist config is introduced alongside phpcs.xml)
  • /.distignore (legacy, if any tool expects it)

Not blocking — none of these appear to exist today based on composer.json.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.gitattributes around lines 1 - 18, Add optional dev/config patterns to
.gitattributes to ensure they are excluded from release archives; specifically
add leading-slash anchored entries for /.editorconfig, /.prettierrc*,
/.eslintrc*, /package.json, /package-lock.json, /node_modules/,
/.phpcs.xml.dist, and /.distignore so these top-level config and node artifacts
never get packaged into export zip files; update the .gitattributes file by
appending these export-ignore lines using the same anchoring and trailing-slash
conventions already present.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In @.gitattributes:
- Around line 1-18: Add optional dev/config patterns to .gitattributes to ensure
they are excluded from release archives; specifically add leading-slash anchored
entries for /.editorconfig, /.prettierrc*, /.eslintrc*, /package.json,
/package-lock.json, /node_modules/, /.phpcs.xml.dist, and /.distignore so these
top-level config and node artifacts never get packaged into export zip files;
update the .gitattributes file by appending these export-ignore lines using the
same anchoring and trailing-slash conventions already present.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 33307b83-c2c4-4131-ad5c-6e91d984fe3e

📥 Commits

Reviewing files that changed from the base of the PR and between a0d1b8c and 71fe3e7.

📒 Files selected for processing (3)
  • .gitattributes
  • .github/workflows/release.yml
  • .github/workflows/test.yml

@guibranco guibranco merged commit 996bb3f into main Apr 24, 2026
14 checks passed
@guibranco guibranco deleted the chore/use-git-attributes branch April 24, 2026 10:38
@penify-dev
Copy link
Copy Markdown

penify-dev Bot commented Apr 24, 2026

Failed to generate code suggestions for PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

☑️ auto-merge Automatic merging of pull requests (gstraccini-bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants