mirror of
https://github.com/hanzoai/forge.git
synced 2026-10-30 15:00:39 +00:00
Source files keep their SPDX-License-Identifier and Hanzo copyright line; the Gitea, Gogs and LFS Test Server copyrights they used to repeat now live once in NOTICE, alongside LICENSE. The header lint accepts any copyright line above the SPDX line, so it no longer demands an upstream one. Co-authored-by: Hanzo Dev <[email protected]>
37 lines
966 B
Go
37 lines
966 B
Go
// Copyright 2026 Hanzo AI, Inc. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
//go:build gogit
|
|
|
|
package git
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
|
|
gitlog "github.com/hanzoai/git/modules/log"
|
|
|
|
commitgraph "github.com/go-git/go-git/v5/plumbing/format/commitgraph/v2"
|
|
cgobject "github.com/go-git/go-git/v5/plumbing/object/commitgraph"
|
|
)
|
|
|
|
// CommitNodeIndex returns the index for walking commit graph
|
|
func (repo *Repository) CommitNodeIndex() (cgobject.CommitNodeIndex, *os.File) {
|
|
indexPath := filepath.Join(repo.Path, "objects", "info", "commit-graph")
|
|
|
|
file, err := os.Open(indexPath)
|
|
if err == nil {
|
|
var index commitgraph.Index
|
|
index, err = commitgraph.OpenFileIndex(file)
|
|
if err == nil {
|
|
return cgobject.NewGraphCommitNodeIndex(index, repo.gogitRepo.Storer), file
|
|
}
|
|
}
|
|
|
|
if !os.IsNotExist(err) {
|
|
gitlog.Warn("Unable to read commit-graph for %s: %v", repo.Path, err)
|
|
}
|
|
|
|
return cgobject.NewObjectCommitNodeIndex(repo.gogitRepo.Storer), nil
|
|
}
|