MCPcopy Create free account
hub / github.com/google/git-appraise / getRefHashes

Method getRefHashes

repository/git.go:1005–1025  ·  view source on GitHub ↗
(refPattern string)

Source from the content-addressed store, hash-verified

1003}
1004
1005func (repo *GitRepo) getRefHashes(refPattern string) (map[string]string, error) {
1006 if !strings.HasSuffix(refPattern, "/*") {
1007 return nil, fmt.Errorf("unsupported ref pattern %q", refPattern)
1008 }
1009 refPrefix := strings.TrimSuffix(refPattern, "*")
1010 showRef, err := repo.runGitCommand("show-ref")
1011 if err != nil {
1012 return nil, err
1013 }
1014 refsMap := make(map[string]string)
1015 for _, line := range strings.Split(showRef, "\n") {
1016 lineParts := strings.Split(line, " ")
1017 if len(lineParts) != 2 {
1018 return nil, fmt.Errorf("unexpected line in output of `git show-ref`: %q", line)
1019 }
1020 if strings.HasPrefix(lineParts[1], refPrefix) {
1021 refsMap[lineParts[1]] = lineParts[0]
1022 }
1023 }
1024 return refsMap, nil
1025}
1026
1027func getRemoteNotesRef(remote, localNotesRef string) string {
1028 // Note: The pattern for remote notes deviates from that of remote heads and devtools,

Callers 3

MergeNotesMethod · 0.95
MergeArchivesMethod · 0.95

Calls 1

runGitCommandMethod · 0.95

Tested by

no test coverage detected