Skip to content

Fix incorrect vendored detections#36508

Merged
wxiaoguang merged 27 commits intomainfrom
copilot/fix-issue-22618
Feb 1, 2026
Merged

Fix incorrect vendored detections#36508
wxiaoguang merged 27 commits intomainfrom
copilot/fix-issue-22618

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 1, 2026

Fixes: #22618

go-enry's IsVendor function marks git paths (.gitignore, .gitattributes, .gitmodules), github/gitea paths (.github/, .gitea/) as "vendored" for GitHub Linguist language statistics. This causes these files to incorrectly display the "Vendored" tag in diff views.

Override go-enry's detection for these specific cases while preserving its behavior for actual vendor directories.

Before, incorrect detections:

Screenshot 2026-02-01 at 08 13 24

After, ok:

Screenshot 2026-02-01 at 08 13 04

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Feb 1, 2026
Copilot AI and others added 2 commits February 1, 2026 06:49
The go-enry library's IsVendor function marks many files as "vendored"
for language statistics purposes (e.g., .gitignore, .gitattributes,
.github/, testdata/, minified files). However, in Gitea's diff view,
showing these as "Vendored" is confusing.

This commit implements a more restrictive vendor detection that only
returns true for files in actual vendor directories:
- vendor/, vendors/
- node_modules/
- bower_components/
- Godeps/
- third_party/, 3rdparty/
- external/, externals/

Fixes #22618

Co-authored-by: silverwind <115237+silverwind@users.noreply.github.com>
Address code review feedback: use path component matching instead of
substring matching to avoid false positives like "myvendor/file.go"
or "external_lib/file.go" being incorrectly marked as vendored.

Co-authored-by: silverwind <115237+silverwind@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix issue 22618 in Gitea Fix vendored detection to only mark actual vendor directories Feb 1, 2026
Copilot AI requested a review from silverwind February 1, 2026 06:51
Use go-enry's IsVendor function but override its detection for:
- .gitignore, .gitattributes, .gitmodules files
- Files in .github/ directory

These files are marked as "vendored" by go-enry for language statistics
purposes, but shouldn't show as "Vendored" in Gitea's diff view.

Fixes #22618

Co-authored-by: silverwind <115237+silverwind@users.noreply.github.com>
Copilot AI changed the title Fix vendored detection to only mark actual vendor directories Fix incorrect vendored detection for .gitignore, .gitattributes, and .github files Feb 1, 2026
- Add .gitea/ directory to the override list
- Simplify condition: paths are relative to repo root, so only
  strings.HasPrefix is needed (removed strings.Contains check)

Co-authored-by: silverwind <115237+silverwind@users.noreply.github.com>
Copilot AI changed the title Fix incorrect vendored detection for .gitignore, .gitattributes, and .github files Fix incorrect vendored detection for .gitignore, .gitattributes, .github, and .gitea files Feb 1, 2026
Copilot AI requested a review from silverwind February 1, 2026 07:03
Restore original go-enry test cases and add new test cases for
the override functionality (.gitignore, .gitattributes, .gitmodules,
.github/, .gitea/).

Co-authored-by: silverwind <115237+silverwind@users.noreply.github.com>
Replace strings.HasPrefix with a compiled regex pattern for
better maintainability.

Co-authored-by: silverwind <115237+silverwind@users.noreply.github.com>
@silverwind silverwind changed the title Fix incorrect vendored detection for .gitignore, .gitattributes, .github, and .gitea files Fix incorrect vendored detections Feb 1, 2026
Include .forgejo/ directory alongside .github/ and .gitea/ in the
regex pattern for directories that shouldn't be marked as vendored.

Co-authored-by: silverwind <115237+silverwind@users.noreply.github.com>
Copilot AI changed the title Fix incorrect vendored detections Fix incorrect vendored detection for .gitignore, .gitattributes, .github, .gitea, and .forgejo files Feb 1, 2026
Signed-off-by: silverwind <me@silverwind.io>
Signed-off-by: silverwind <me@silverwind.io>
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Feb 1, 2026
@wxiaoguang wxiaoguang enabled auto-merge (squash) February 1, 2026 09:15
@silverwind silverwind added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Feb 1, 2026
@wxiaoguang wxiaoguang merged commit 584d8ef into main Feb 1, 2026
28 checks passed
@GiteaBot GiteaBot added this to the 1.26.0 milestone Feb 1, 2026
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Feb 1, 2026
@silverwind silverwind deleted the copilot/fix-issue-22618 branch February 1, 2026 10:40
silverwind added a commit to silverwind/gitea that referenced this pull request Feb 1, 2026
* origin/main:
  Fix incorrect vendored detections (go-gitea#36508)
  Bump alpine to 3.23, add platforms to `docker-dryrun` (go-gitea#36379)
  Unify repo names in system notices (go-gitea#36491)
  Allow scroll propagation outside code editor (go-gitea#36502)
  Refactor ActionsTaskID (go-gitea#36503)
  Update JS deps, remove `knip`, misc tweaks (go-gitea#36499)
  [skip ci] Updated translations via Crowdin
  Fix editorconfig not respected in PR Conversation view (go-gitea#36492)
  Add FOLDER_ICON_THEME configuration option (go-gitea#36496)
  Don't create self-references in merged PRs (go-gitea#36490)
  Use reserved .test TLD for unit tests (go-gitea#36498)
  Fix bug when list pull request commits (go-gitea#36485)
  Update some go dependencies (go-gitea#36489)
  chore: add comments for "api/healthz", clean up test env (go-gitea#36481)
zjjhot added a commit to zjjhot/gitea that referenced this pull request Feb 2, 2026
* giteaofficial/main: (26 commits)
  [skip ci] Updated translations via Crowdin
  Remove and forbid `@ts-expect-error` (go-gitea#36513)
  Add resolve/unresolve review comment API endpoints (go-gitea#36441)
  Fix incorrect vendored detections (go-gitea#36508)
  Bump alpine to 3.23, add platforms to `docker-dryrun` (go-gitea#36379)
  Unify repo names in system notices (go-gitea#36491)
  Allow scroll propagation outside code editor (go-gitea#36502)
  Refactor ActionsTaskID (go-gitea#36503)
  Update JS deps, remove `knip`, misc tweaks (go-gitea#36499)
  [skip ci] Updated translations via Crowdin
  Fix editorconfig not respected in PR Conversation view (go-gitea#36492)
  Add FOLDER_ICON_THEME configuration option (go-gitea#36496)
  Don't create self-references in merged PRs (go-gitea#36490)
  Use reserved .test TLD for unit tests (go-gitea#36498)
  Fix bug when list pull request commits (go-gitea#36485)
  Update some go dependencies (go-gitea#36489)
  chore: add comments for "api/healthz", clean up test env (go-gitea#36481)
  [SECURITY] Toolchain Update to Go 1.25.6 (go-gitea#36480)
  [skip ci] Updated translations via Crowdin
  Render merged pull request title as such in dashboard feed (go-gitea#36479)
  ...
silverwind added a commit to silverwind/gitea that referenced this pull request Feb 4, 2026
* origin/main: (1246 commits)
  fix(packages/container): data race when uploading container blobs concurrently (go-gitea#36524)
  [skip ci] Updated translations via Crowdin
  Remove and forbid `@ts-expect-error` (go-gitea#36513)
  Add resolve/unresolve review comment API endpoints (go-gitea#36441)
  Fix incorrect vendored detections (go-gitea#36508)
  Bump alpine to 3.23, add platforms to `docker-dryrun` (go-gitea#36379)
  Unify repo names in system notices (go-gitea#36491)
  Allow scroll propagation outside code editor (go-gitea#36502)
  Refactor ActionsTaskID (go-gitea#36503)
  Update JS deps, remove `knip`, misc tweaks (go-gitea#36499)
  [skip ci] Updated translations via Crowdin
  Fix editorconfig not respected in PR Conversation view (go-gitea#36492)
  Add FOLDER_ICON_THEME configuration option (go-gitea#36496)
  Don't create self-references in merged PRs (go-gitea#36490)
  Use reserved .test TLD for unit tests (go-gitea#36498)
  Fix bug when list pull request commits (go-gitea#36485)
  Update some go dependencies (go-gitea#36489)
  chore: add comments for "api/healthz", clean up test env (go-gitea#36481)
  [SECURITY] Toolchain Update to Go 1.25.6 (go-gitea#36480)
  [skip ci] Updated translations via Crowdin
  ...

# Conflicts:
#	modules/templates/helper.go
#	options/locale/locale_en-US.ini
#	routers/web/repo/cherry_pick.go
#	routers/web/repo/editor.go
#	routers/web/repo/patch.go
#	templates/repo/editor/edit.tmpl
#	web_src/js/features/codeeditor.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/docs modifies/go Pull requests that update Go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.gitignore and .gitattribute incorrectly detected as "vendored"

4 participants