oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1package equipo
2
3import (
4 "strconv"
5
6 "amadan.net/oficina/equipo/internal/equipo/planning"
7 "amadan.net/oficina/equipo/internal/equipo/team"
8 "amadan.net/oficina/equipo/internal/taskplan"
9 "gorm.io/gorm"
10)
11
12func PlanJobSpec(task Task, project Project, p taskplan.Plan, policy team.Policy) (team.JobSpec, error) {
13 if task.TeamID == "" || !validAddress(task.Requester) || task.ProjectID != project.ID || project.ID <= 0 {
14 return team.JobSpec{}, ErrInvalid
15 }
16 repository, err := canonicalRepository(project.Repository)
17 if err != nil || repository != project.Repository {
18 return team.JobSpec{}, ErrInvalid
19 }
20 target := team.TargetBinding{Kind: team.TargetProjectRead, Repository: project.Repository, BaseRevision: "project/" + strconv.FormatInt(project.Revision, 10)}
21 if taskplan.Publication(p.Kind) {
22 t := task
23 if t.Description == "" {
24 t.Description = t.ID
25 }
26 spec, err := BugJobSpec(t, project, policy, t.Description)
27 if err != nil {
28 return team.JobSpec{}, err
29 }
30 target = spec.Target
31 }
32 return planning.ExecutionSpec(task, p, target, policy, GrantRef(project.ID, task.Requester))
33}
34
35// stepAt resolves persisted actions; step keys never choose capabilities.
36func (s *Store) stepAt(tx *gorm.DB, t Task, key string) (taskplan.Plan, taskplan.Step, error) {
37 p, err := s.planningAt(tx).Plan(t)
38 if err != nil {
39 return p, taskplan.Step{}, err
40 }
41 st, err := planning.ResolveStep(p, key, ErrInvalid)
42 return p, st, err
43}
44
45func executionSpecialist(st taskplan.Step) string { return planning.ExecutionSpecialist(st) }
46func (s *Store) dispatchSelection(tx *gorm.DB, t Task, st taskplan.Step, first Selection) (Selection, error) {
47 return s.selectionPolicy().Dispatch(tx, t, st, first)
48}
49