MCPcopy Index your code
hub / github.com/google/git-appraise / StoreBlob

Method StoreBlob

repository/git.go:537–548  ·  view source on GitHub ↗

StoreBlob writes the given file to the repository and returns its hash.

(contents string)

Source from the content-addressed store, hash-verified

535
536// StoreBlob writes the given file to the repository and returns its hash.
537func (repo *GitRepo) StoreBlob(contents string) (string, error) {
538 stdin := strings.NewReader(contents)
539 var stdout bytes.Buffer
540 var stderr bytes.Buffer
541 args := []string{"hash-object", "-w", "-t", "blob", "--stdin"}
542 err := repo.runGitCommandWithIO(stdin, &stdout, &stderr, args...)
543 if err != nil {
544 message := strings.TrimSpace(stderr.String())
545 return "", fmt.Errorf("failure storing a git blob, %v: %q", err, message)
546 }
547 return strings.TrimSpace(stdout.String()), nil
548}
549
550// StoreTree writes the given file tree to the repository and returns its hash.
551func (repo *GitRepo) StoreTree(contents map[string]TreeChild) (string, error) {

Callers

nothing calls this directly

Calls 2

runGitCommandWithIOMethod · 0.95
StringMethod · 0.80

Tested by

no test coverage detected