mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 21:28:11 +09:00 
			
		
		
		
	Abstract hash function usage (#28138)
Refactor Hash interfaces and centralize hash function. This will allow easier introduction of different hash function later on. This forms the "no-op" part of the SHA256 enablement patch.
This commit is contained in:
		| @@ -9,7 +9,7 @@ import ( | ||||
| 	"io" | ||||
| ) | ||||
|  | ||||
| func (repo *Repository) getTree(id SHA1) (*Tree, error) { | ||||
| func (repo *Repository) getTree(id ObjectID) (*Tree, error) { | ||||
| 	wr, rd, cancel := repo.CatFileBatch(repo.Ctx) | ||||
| 	defer cancel() | ||||
|  | ||||
| @@ -28,7 +28,7 @@ func (repo *Repository) getTree(id SHA1) (*Tree, error) { | ||||
| 		if err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		tag, err := parseTagData(data) | ||||
| 		tag, err := parseTagData(id.Type(), data) | ||||
| 		if err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| @@ -51,7 +51,7 @@ func (repo *Repository) getTree(id SHA1) (*Tree, error) { | ||||
| 	case "tree": | ||||
| 		tree := NewTree(repo, id) | ||||
| 		tree.ResolvedID = id | ||||
| 		tree.entries, err = catBatchParseTreeEntries(tree, rd, size) | ||||
| 		tree.entries, err = catBatchParseTreeEntries(repo.objectFormat, tree, rd, size) | ||||
| 		if err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| @@ -66,7 +66,7 @@ func (repo *Repository) getTree(id SHA1) (*Tree, error) { | ||||
|  | ||||
| // GetTree find the tree object in the repository. | ||||
| func (repo *Repository) GetTree(idStr string) (*Tree, error) { | ||||
| 	if len(idStr) != SHAFullLength { | ||||
| 	if len(idStr) != repo.objectFormat.FullLength() { | ||||
| 		res, err := repo.GetRefCommitID(idStr) | ||||
| 		if err != nil { | ||||
| 			return nil, err | ||||
| @@ -75,7 +75,7 @@ func (repo *Repository) GetTree(idStr string) (*Tree, error) { | ||||
| 			idStr = res | ||||
| 		} | ||||
| 	} | ||||
| 	id, err := NewIDFromString(idStr) | ||||
| 	id, err := repo.objectFormat.NewIDFromString(idStr) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user