diff options
author | Runxi Yu <me@runxiyu.org> | 2025-04-06 01:30:02 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-04-06 01:30:02 +0800 |
commit | 7b7e20e60c1c6b858ae0c4eb78d414912263642f (patch) | |
tree | 988bc0a39e142dcfd52af98ec65e11578474002c /git_misc.go | |
parent | irc: Factor the IRC stuff into its own package (diff) | |
download | forge-7b7e20e60c1c6b858ae0c4eb78d414912263642f.tar.gz forge-7b7e20e60c1c6b858ae0c4eb78d414912263642f.tar.zst forge-7b7e20e60c1c6b858ae0c4eb78d414912263642f.zip |
oldgit: Separate some go-git stuff into here
Diffstat (limited to 'git_misc.go')
-rw-r--r-- | git_misc.go | 32 |
1 files changed, 0 insertions, 32 deletions
diff --git a/git_misc.go b/git_misc.go index 40247f1..83ee11c 100644 --- a/git_misc.go +++ b/git_misc.go @@ -10,7 +10,6 @@ import ( "iter" "github.com/go-git/go-git/v5" - "github.com/go-git/go-git/v5/plumbing" "github.com/go-git/go-git/v5/plumbing/object" "github.com/jackc/pgx/v5/pgtype" ) @@ -86,34 +85,3 @@ func commitIterSeqErr(commitIter object.CommitIter) (iter.Seq[*object.Commit], * } }, &err } - -// 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 -} - -var nullTree object.Tree //nolint:gochecknoglobals |