StoreBlob writes the given file to the repository and returns its hash.
(contents string)
| 535 | |
| 536 | // StoreBlob writes the given file to the repository and returns its hash. |
| 537 | func (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. |
| 551 | func (repo *GitRepo) StoreTree(contents map[string]TreeChild) (string, error) { |
nothing calls this directly
no test coverage detected