diff options
author | Runxi Yu <me@runxiyu.org> | 2025-08-12 11:01:07 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-08-12 11:01:07 +0800 |
commit | dd6e40c759004c4c15944aed1289358bda038848 (patch) | |
tree | 02d0dd390a2d60d90f77106cce93befd85ca1b14 /forged/internal/oldgit/patch.go | |
parent | Remove forge-specific functions from misc (diff) | |
download | forge-dd6e40c759004c4c15944aed1289358bda038848.tar.gz forge-dd6e40c759004c4c15944aed1289358bda038848.tar.zst forge-dd6e40c759004c4c15944aed1289358bda038848.zip |
Remove the mess
Diffstat (limited to 'forged/internal/oldgit/patch.go')
-rw-r--r-- | forged/internal/oldgit/patch.go | 43 |
1 files changed, 0 insertions, 43 deletions
diff --git a/forged/internal/oldgit/patch.go b/forged/internal/oldgit/patch.go deleted file mode 100644 index fc8ef98..0000000 --- a/forged/internal/oldgit/patch.go +++ /dev/null @@ -1,43 +0,0 @@ -// SPDX-License-Identifier: AGPL-3.0-only -// SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org> - -package oldgit - -import ( - "errors" - - "github.com/go-git/go-git/v5/plumbing" - "github.com/go-git/go-git/v5/plumbing/object" -) - -// CommitToPatch creates an [object.Patch] from the first parent of a given -// [object.Commit]. -// -// TODO: This function should be deprecated as it only diffs with the first -// parent and does not correctly handle merge commits. -func CommitToPatch(commit *object.Commit) (parentCommitHash plumbing.Hash, patch *object.Patch, err error) { - var parentCommit *object.Commit - var commitTree *object.Tree - - parentCommit, err = commit.Parent(0) - switch { - case errors.Is(err, object.ErrParentNotFound): - if commitTree, err = commit.Tree(); err != nil { - return - } - if patch, err = NullTree.Patch(commitTree); err != nil { - return - } - case err != nil: - return - default: - parentCommitHash = parentCommit.Hash - if patch, err = parentCommit.Patch(commit); err != nil { - return - } - } - return -} - -// NullTree is a tree object that is empty and has no hash. -var NullTree object.Tree //nolint:gochecknoglobals |