code: func parseCommit(s string) (commit *pb.GitilesCommit, mustConfirmRef bool, err error) {
  	m := regexCommit.FindStringSubmatch(s)
  	if m == nil {
  		return nil, false, errMalformedCommitString
  	}
  	commit = &pb.GitilesCommit{
  		Host:    m[1],
  		Project: m[2],
  		Id:      m[4],
  		Ref:     m[5],
  	}
  
  	ref := strings.Split(commit.Ref, "/")
  	// Apply heuristic.
  	switch {
  	case commit.Id != "":
  		// This is a precise commit.
  
  	case strings.HasPrefix(commit.Ref, "refs/heads/"):
  		// Take one component after refs/heads/
  		commit.Ref = strings.Join(ref[:3], "/")
  		mustConfirmRef = len(ref) > 3
  
  	case !strings.HasPrefix(commit.Ref, "refs/"):
  		// Suspect a branch.
  		commit.Ref = "refs/heads/" + ref[0]
  		mustConfirmRef = true
  
  	default:
  		// The user has specified something with prefix "refs/", but without
  		// prefix "refs/heads/". They must know what they is doing.
  		mustConfirmRef = true
  
  	}
  	return
  }
docs: // parseCommit tries to retrieve a Gitiles Commit from a string.
  //
  // It is not strict or precise, and can consume noisy strings, e.g.
  // https://chromium.googlesource.com/chromium/src/+/34e1ee99cc34fa86a1c2699977e223a13eb5f96c/chrome/test/chromedriver/test/run_py_tests.py
  // If err is nil, returned commit is guaranteed to have Host, Project and
  // either Ref or Id.
  //
  // If mustConfirmRef is true, commit.Ref needs to be confirmed.