Files

32 lines
751 B
Go
Raw Permalink Normal View History

2021-04-01 18:41:09 +01:00
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
2021-04-01 18:41:09 +01:00
package analyze
import (
2026-02-01 10:35:51 +00:00
"path"
"strings"
2022-05-06 09:12:30 +00:00
"github.com/go-enry/go-enry/v2"
2021-04-01 18:41:09 +01:00
)
2026-02-01 10:35:51 +00:00
// IsVendor returns whether the path is a vendor path.
// It uses go-enry's IsVendor function but overrides its detection for certain
// special cases that shouldn't be marked as vendored in the diff view.
func IsVendor(treePath string) bool {
if !enry.IsVendor(treePath) {
return false
}
// Override detection for single files
basename := path.Base(treePath)
switch basename {
case ".gitignore", ".gitattributes", ".gitmodules":
return false
}
if strings.HasPrefix(treePath, ".github/") || strings.HasPrefix(treePath, ".gitea/") {
return false
}
return true
2021-04-01 18:41:09 +01:00
}