Kiln » gitkiln Read More
Clone URL:  
Pushed to one repository · View In Graph Contained in master

refactor the KilnClient methods so that you can get a repo object, or merely its ID

Changeset a21d9c6381f0

Parent c655525136b5

by Profile picture of User 12Benjamin Pollack <benjamin@fogcreek.com>

Changes to one file · Browse files at a21d9c6381f0 Showing diff from parent c655525136b5 Diff from another changeset...

Change 1 of 1 Show Entire File kiln/​api.go Stacked
 
65
66
67
68
 
69
70
71
72
 
73
74
75
 
76
77
78
79
80
81
82
83
 
84
85
86
87
88
89
90
 
 
 
 
 
 
 
 
 
91
92
93
 
65
66
67
 
68
69
70
 
 
71
72
 
 
73
74
75
76
77
78
79
 
 
80
81
82
83
84
85
 
 
86
87
88
89
90
91
92
93
94
95
96
97
@@ -65,29 +65,33 @@
  return  }   -func (k *KilnClient) IdForRepo(repoPath string) (repoId int64, err error) { +func (k *KilnClient) RepoForPath(repoPath string) (*KilnRepo, error) {   parts := strings.Split(repoPath, "/")   if len(parts) != 3 { - err = fmt.Errorf("unknown repository target: %v", repoPath) - return + return nil, fmt.Errorf("unknown repository target: %v", repoPath)   } - var projects []KilnProject - if projects, err = k.Projects(); err == nil { + if projects, err := k.Projects(); err == nil {   for _, project := range projects {   for _, repoGroup := range project.RepoGroups {   for _, repo := range repoGroup.Repos {   if strings.EqualFold(repo.ProjectSlug, parts[0]) &&   strings.EqualFold(repo.GroupSlug, parts[1]) &&   strings.EqualFold(repo.Slug, parts[2]) { - repoId = repo.Id - return + return &repo, nil   }   }   }   }   } - err = fmt.Errorf("repository not found") - return + return nil, fmt.Errorf("repository not found") +} + +func (k *KilnClient) IdForRepo(repoPath string) (int64, error) { + repo, err := k.RepoForPath(repoPath) + if err != nil { + return -1, err + } + return repo.Id, nil  }    func (k *KilnClient) RelatedRepos(repoPath string) (repos []KilnRepo, err error) {