summaryrefslogtreecommitdiffstats
path: root/modules/git/last_commit_cache_nogogit.go
diff options
context:
space:
mode:
authorGusted <postmaster@gusted.xyz>2024-08-12 17:16:55 +0200
committerGusted <postmaster@gusted.xyz>2024-08-12 19:11:09 +0200
commita21128a734636c2a18431cfc1742e8a7cf165f58 (patch)
tree0be943aba5a74765fb99f00f615fb995dd9f170b /modules/git/last_commit_cache_nogogit.go
parentMerge pull request 'git-grep: ensure bounded default for MatchesPerFile' (#49... (diff)
downloadforgejo-a21128a734636c2a18431cfc1742e8a7cf165f58.tar.xz
forgejo-a21128a734636c2a18431cfc1742e8a7cf165f58.zip
[CHORE] Drop `go-git` support
See https://codeberg.org/forgejo/discussions/issues/164 for the rationale and discussion of this change. Everything related to the `go-git` dependency is dropped (Only a single instance is left in a test file to test for an XSS, it requires crafting an commit that Git itself refuses to craft). `_gogit` files have been removed entirely, `go:build: !gogit` is removed, `XXX_nogogit.go` files either have been renamed or had their code being merged into the `XXX.go` file.
Diffstat (limited to 'modules/git/last_commit_cache_nogogit.go')
-rw-r--r--modules/git/last_commit_cache_nogogit.go54
1 files changed, 0 insertions, 54 deletions
diff --git a/modules/git/last_commit_cache_nogogit.go b/modules/git/last_commit_cache_nogogit.go
deleted file mode 100644
index 155cb3cb7c..0000000000
--- a/modules/git/last_commit_cache_nogogit.go
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright 2020 The Gitea Authors. All rights reserved.
-// SPDX-License-Identifier: MIT
-
-//go:build !gogit
-
-package git
-
-import (
- "context"
-)
-
-// CacheCommit will cache the commit from the gitRepository
-func (c *Commit) CacheCommit(ctx context.Context) error {
- if c.repo.LastCommitCache == nil {
- return nil
- }
- return c.recursiveCache(ctx, &c.Tree, "", 1)
-}
-
-func (c *Commit) recursiveCache(ctx context.Context, tree *Tree, treePath string, level int) error {
- if level == 0 {
- return nil
- }
-
- entries, err := tree.ListEntries()
- if err != nil {
- return err
- }
-
- entryPaths := make([]string, len(entries))
- for i, entry := range entries {
- entryPaths[i] = entry.Name()
- }
-
- _, err = WalkGitLog(ctx, c.repo, c, treePath, entryPaths...)
- if err != nil {
- return err
- }
-
- for _, treeEntry := range entries {
- // entryMap won't contain "" therefore skip this.
- if treeEntry.IsDir() {
- subTree, err := tree.SubTree(treeEntry.Name())
- if err != nil {
- return err
- }
- if err := c.recursiveCache(ctx, subTree, treeEntry.Name(), level-1); err != nil {
- return err
- }
- }
- }
-
- return nil
-}