fixed issues from opencode agent
This commit is contained in:
@@ -69,7 +69,10 @@ func (s *Scanner) scanPush(evt events.PushEvent) {
|
||||
|
||||
// Resolve repo.
|
||||
var repo models.Repository
|
||||
if found, _ := s.db.ID(evt.RepoID).Get(&repo); !found {
|
||||
if found, err := s.db.ID(evt.RepoID).Get(&repo); err != nil {
|
||||
log.Printf("scanning: look up repo %d: %v", evt.RepoID, err)
|
||||
return
|
||||
} else if !found {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -112,11 +115,11 @@ func (s *Scanner) scanPush(evt events.PushEvent) {
|
||||
|
||||
// getDiff returns the unified diff of all changes between two refs.
|
||||
func (s *Scanner) getDiff(repoPath, oldRef, newRef string) ([]byte, error) {
|
||||
// If oldRef is the zero OID (new branch), just get the initial commit content.
|
||||
// If oldRef is the zero OID (new branch), diff-tree against the empty tree so
|
||||
// we get actual file contents rather than ls-tree metadata.
|
||||
zeroOID := "0000000000000000000000000000000000000000"
|
||||
if oldRef == zeroOID {
|
||||
// Show the entire tree at the new ref.
|
||||
out, err := gitdomain.Run(repoPath, "ls-tree", "-r", newRef)
|
||||
out, err := gitdomain.Run(repoPath, "diff-tree", "--no-commit-id", "-r", "-p", newRef)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user