// ParseBranchID parses a hex encoded BranchID. Returns NullBranchID
// and an InvalidBranchID on falire.
330152
func ParseBranchID(s string) (BranchID, error) {
	if len(s) != BranchIDStringLen {
		return NullBranchID, InvalidBranchID{s}
	}
	bytes, err := hex.DecodeString(s)
	if err != nil {
		return NullBranchID, InvalidBranchID{s}
	}
	var id BranchID
	err = id.UnmarshalBinary(bytes)
	if err != nil {
		return NullBranchID, InvalidBranchID{s}
	}
	return id, nil
}
954553
func (t *Trie) GetBranch(entry string) *Branch {
	return t.Root.getBranch([]byte(entry))
}
616091
func ParseMigration(id string, r io.ReadSeeker) (*Migration, error) {
	m := &Migration{
		Id: id,
	}

	parsed, err := sqlparse.ParseMigration(r)
	if err != nil {
		return nil, fmt.Errorf("Error parsing migration (%s): %s", id, err)
	}

	m.Up = parsed.UpStatements
	m.Down = parsed.DownStatements

	m.DisableTransactionUp = parsed.DisableTransactionUp
	m.DisableTransactionDown = parsed.DisableTransactionDown

	return m, nil
}
1282787
func ParseStellarAccountID(idStr string) (stellar1.AccountID, error) {
	idStr = strings.ToUpper(idStr)
	if len(idStr) != 56 {
		return "", NewInvalidStellarAccountIDError(fmt.Sprintf("Stellar account ID must be 56 chars long: was %v", len(idStr)))
	}
	_, err := base32.StdEncoding.DecodeString(idStr)
	if err != nil {
		return "", NewInvalidStellarAccountIDError("invalid characters in Stellar account ID")
	}
	kp, err := keypair.Parse(idStr)
	if err != nil {
		return "", NewInvalidStellarAccountIDError(fmt.Sprintf("invalid Stellar account ID key: %s", err))
	}
	switch kp := kp.(type) {
	case *keypair.FromAddress:
		return stellar1.AccountID(kp.Address()), nil
	case *keypair.Full:
		return "", NewInvalidStellarAccountIDError("unexpected Stellar secret key, expected account ID")
	default:
		return "", NewInvalidStellarAccountIDError("invalid keypair type")
	}
}
544680
func (b *Branch) hasBranch(idx byte) bool {
	if _, present := b.Branches[idx]; present {
		return true
	}
	return false
}
347909
func ParseBase58(b []byte) (ID, error) {

	var id int64

	for i := range b {
		if decodeBase58Map[b[i]] == 0xFF {
			return -1, ErrInvalidBase58
		}
		id = id*58 + int64(decodeBase58Map[b[i]])
	}

	return ID(id), nil
}
1229110
func getBranch(projects []che.WorkspaceProject, codebaseURL string) string {
	for _, p := range projects {
		if p.Source.Location == codebaseURL {
			return p.Source.Parameters.Branch
		}
	}
	return ""
}
161657
func (c *Client) TrackBranch(branchName string, entities []string) error {
	var result params.ErrorResults
	arg := params.BranchTrackArg{
		BranchName: branchName,
	}
	if len(entities) == 0 {
		return errors.New("no units or applications specified")
	}
	for _, entity := range entities {
		switch {
		case names.IsValidApplication(entity):
			arg.Entities = append(arg.Entities,
				params.Entity{Tag: names.NewApplicationTag(entity).String()})
		case names.IsValidUnit(entity):
			arg.Entities = append(arg.Entities,
				params.Entity{Tag: names.NewUnitTag(entity).String()})
		default:
			return errors.Errorf("%q is not an application or a unit", entity)
		}
	}
	err := c.facade.FacadeCall("TrackBranch", arg, &result)
	if err != nil {
		return errors.Trace(err)
	}

	if err := result.Combine(); err != nil {
		return errors.Trace(err)
	}
	return nil
}
994926
func (repo *Repository) GetBranchCommitID(name string) (string, error) {
	return repo.getRefCommitID(BRANCH_PREFIX + name)
}
734062
func ParseCIDR(s string) (*CIDR, error) {
	_, net, err := net.ParseCIDR(s)
	if err != nil {
		return nil, err
	}
	return &CIDR{*net}, nil
}
846643
func (s *ProjectsService) DeleteBranch(projectName, branchID string) (*Response, error) {
	u := fmt.Sprintf("projects/%s/branches/%s", url.QueryEscape(projectName), url.QueryEscape(branchID))
	return s.client.DeleteRequest(u, nil)
}
982940
func (m *MockBranchCommandAPI) AddBranch(arg0 string) error {
	ret := m.ctrl.Call(m, "AddBranch", arg0)
	ret0, _ := ret[0].(error)
	return ret0
}
240379
func ParseUUID(s string) (*UUID, error) {
	u := &UUID{}
	if err := u.UnmarshalText([]byte(s)); err != nil {
		return nil, err
	}
	return u, nil
}
247220
func (c *Configuration) RemoteBranchForLocalBranch(localBranch string) string {
	// get remote ref to track, may not be same name
	merge := c.Find(fmt.Sprintf("branch.%s.merge", localBranch))
	if strings.HasPrefix(merge, "refs/heads/") {
		return merge[11:]
	} else {
		return localBranch
	}
}
576372
func (repo *Repository) GetRemoteBranchCommit(name string) (*Commit, error) {
	commitID, err := repo.GetRemoteBranchCommitID(name)
	if err != nil {
		return nil, err
	}
	return repo.GetCommit(commitID)
}
648044
func IsBranchSynchronized(branch, remote string) (bool, error) {
	exists, err := RemoteBranchExists(branch, remote)
	if err != nil {
		return false, err
	}
	if !exists {
		return true, nil
	}

	var (
		localRef  = "refs/heads/" + branch
		remoteRef = "refs/remotes/" + remote + "/" + branch
	)
	localHexsha, err := Hexsha(localRef)
	if err != nil {
		return false, err
	}
	remoteHexsha, err := Hexsha(remoteRef)
	if err != nil {
		return false, err
	}

	return localHexsha == remoteHexsha, nil
}
644188
func (mr *MockModelMockRecorder) AddBranch(arg0, arg1 interface{}) *gomock.Call {
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddBranch", reflect.TypeOf((*MockModel)(nil).AddBranch), arg0, arg1)
}