// ActiveBranch implements the ModelCommand interface.
16733
func (c *ModelCommandBase) ActiveBranch() (string, error) {
	if c._activeBranch != "" {
		return c._activeBranch, nil
	}
	// If we need to look up the model generation, we need to ensure we
	// have access to the model details.
	if err := c.maybeInitModel(); err != nil {
		return "", errors.Trace(err)
	}
	details, err := c.store.ModelByName(c._controllerName, c._modelName)
	if err != nil {
		if !c.runStarted {
			return "", errors.Trace(err)
		}
		details, err = c.modelDetails(c._controllerName, c._modelName)
		if err != nil {
			return "", errors.Trace(err)
		}
	}
	c._activeBranch = details.ActiveBranch
	return c._activeBranch, nil
}
388704
func (c *Client) CommitBranch(branchName string) (int, error) {
	var result params.IntResult
	err := c.facade.FacadeCall("CommitBranch", argForBranch(branchName), &result)
	if err != nil {
		return 0, errors.Trace(err)
	}
	if result.Error != nil {
		return 0, errors.Trace(result.Error)
	}
	return result.Result, nil
}
835602
func (s *CreateAppInput) SetEnableBranchAutoBuild(v bool) *CreateAppInput {
	s.EnableBranchAutoBuild = &v
	return s
}
471741
func (cmd *PageCommand) PrintBranch(w io.Writer, buf []byte) error {
	p := (*page)(unsafe.Pointer(&buf[0]))

	// Print number of items.
	fmt.Fprintf(w, "Item Count: %d\n", p.count)
	fmt.Fprintf(w, "\n")

	// Print each key/value.
	for i := uint16(0); i < p.count; i++ {
		e := p.branchPageElement(i)

		// Format key as string.
		var k string
		if isPrintable(string(e.key())) {
			k = fmt.Sprintf("%q", string(e.key()))
		} else {
			k = fmt.Sprintf("%x", string(e.key()))
		}

		fmt.Fprintf(w, "%s: <pgid=%d>\n", k, e.pgid)
	}
	fmt.Fprintf(w, "\n")
	return nil
}
1332939
func (s *UpdateBranchOutput) SetBranch(v *Branch) *UpdateBranchOutput {
	s.Branch = v
	return s
}
924664
func (md *MDOpsStandard) PruneBranch(
	ctx context.Context, id tlf.ID, bid kbfsmd.BranchID) error {
	mdserv, err := md.mdserver(ctx)
	if err != nil {
		return err
	}
	return mdserv.PruneBranch(ctx, id, bid)
}
1009235
func (c *branchCommand) Run(ctx *cmd.Context) error {
	client, err := c.getAPI()
	if err != nil {
		return err
	}
	defer func() { _ = client.Close() }()

	if err = client.AddBranch(c.branchName); err != nil {
		return err
	}

	// Update the model store with the new active branch for this model.
	if err = c.SetActiveBranch(c.branchName); err != nil {
		return err
	}

	_, err = ctx.Stdout.Write([]byte(fmt.Sprintf("Active branch set to %q\n", c.branchName)))
	return err
}
709559
func (mr *MockCommitCommandAPIMockRecorder) CommitBranch(arg0 interface{}) *gomock.Call {
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CommitBranch", reflect.TypeOf((*MockCommitCommandAPI)(nil).CommitBranch), arg0)
}
1229110
func getBranch(projects []che.WorkspaceProject, codebaseURL string) string {
	for _, p := range projects {
		if p.Source.Location == codebaseURL {
			return p.Source.Parameters.Branch
		}
	}
	return ""
}
662046
func (s *Shell) Active() bool {
	s.activeMutex.RLock()
	defer s.activeMutex.RUnlock()
	return s.active
}
213623
func (p *PagesSource) GetBranch() string {
	if p == nil || p.Branch == nil {
		return ""
	}
	return *p.Branch
}
1356577
func assertModelActiveOp(modelUUID string) txn.Op {
	return txn.Op{
		C:      modelsC,
		Id:     modelUUID,
		Assert: append(isAliveDoc, bson.DocElem{"migration-mode", MigrationModeNone}),
	}
}
694514
func ActiveProjects(c context.Context) ([]types.ProjectName, error) {
	return ProjectNames(c, cfgclient.AsService)
}
1042010
func (m *MockCommitCommandAPI) CommitBranch(arg0 string) (int, error) {
	ret := m.ctrl.Call(m, "CommitBranch", arg0)
	ret0, _ := ret[0].(int)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}
141688
func (api *API) TrackBranch(arg params.BranchTrackArg) (params.ErrorResults, error) {
	isModelAdmin, err := api.hasAdminAccess()
	if err != nil {
		return params.ErrorResults{}, errors.Trace(err)
	}
	if !isModelAdmin && !api.isControllerAdmin {
		return params.ErrorResults{}, common.ErrPerm
	}

	branch, err := api.model.Branch(arg.BranchName)
	if err != nil {
		return params.ErrorResults{}, errors.Trace(err)
	}

	result := params.ErrorResults{
		Results: make([]params.ErrorResult, len(arg.Entities)),
	}
	for i, entity := range arg.Entities {
		tag, err := names.ParseTag(entity.Tag)
		if err != nil {
			result.Results[i].Error = common.ServerError(err)
			continue
		}
		switch tag.Kind() {
		case names.ApplicationTagKind:
			result.Results[i].Error = common.ServerError(branch.AssignAllUnits(tag.Id()))
		case names.UnitTagKind:
			result.Results[i].Error = common.ServerError(branch.AssignUnit(tag.Id()))
		default:
			result.Results[i].Error = common.ServerError(
				errors.Errorf("expected names.UnitTag or names.ApplicationTag, got %T", tag))
		}
	}
	return result, nil
}
1121038
func (stub *Stub) Active() bool {
	stub.lock.RLock()
	defer stub.lock.RUnlock()
	return stub.isActive()
}
9654
func (m *MockModel) AddBranch(arg0, arg1 string) error {
	ret := m.ctrl.Call(m, "AddBranch", arg0, arg1)
	ret0, _ := ret[0].(error)
	return ret0
}