Changeset 192fa27a9dbc…
Parent b56064d5e3cc…
by Benjamin Pollack <benjamin@fogcreek.com>
Changes to 3 files · Browse files at 192fa27a9dbc Showing diff from parent b56064d5e3cc Diff from another changeset...
|
|
@@ -8,7 +8,7 @@ )
// Represents the error JSON returned by Kiln API requests
-type KilnError struct {
+type ApiError struct {
// Guaranteed-unique code for Kiln errors
Code string `json:"codeError"`
// Human-readable description
@@ -16,50 +16,50 @@}
// Represents the project JSON returned from the Kiln API
-type KilnProject struct {
+type Project struct {
Id int64 `json:"ixProject"`
Slug string `json:"sSlug"`
Name string `json:"sName"`
Description string `json:"sDescription"`
DefaultPermission string `json:"permissionDefault"`
- RepoGroups []KilnRepoGroup
+ RepoGroups []RepoGroup
}
-type KilnRepoGroup struct {
- Id int64 `json:"ixRepoGroup"`
- ProjectId int64 `json:"ixProject"`
- Slug string `json:"sSlug"`
- Name string `json:"sName"`
- Repos []KilnRepo `json:"repos"`
+type RepoGroup struct {
+ Id int64 `json:"ixRepoGroup"`
+ ProjectId int64 `json:"ixProject"`
+ Slug string `json:"sSlug"`
+ Name string `json:"sName"`
+ Repos []Repo `json:"repos"`
}
-type KilnRepo struct {
- Id int64 `json:"ixRepo"`
- RepoGroupId int64 `json:"ixRepoGroup"`
- ParentId int64 `json:"ixParent"`
- IsCentral bool `json:"fCentral"`
- Slug string `json:"sSlug"`
- GroupSlug string `json:"sGroupSlug"`
- ProjectSlug string `json:"sProjectSlug"`
- GitUrl string `json:"sGitUrl"`
- GitSshUrl string `json:"sGitSshUrl"`
- Name string `json:"sName"`
- Description string `json:"sDescription"`
- Status string `json:"sStatus"`
- Size int64 `json:"bytesSize"`
- Vcs int `json:"vcs"`
- Creator KilnPerson `json:"personCreator"`
- DefaultPermission string `json:"permissionDefault"`
- Branches []KilnRepo `json:"repoBranches"`
+type Repo struct {
+ Id int64 `json:"ixRepo"`
+ RepoGroupId int64 `json:"ixRepoGroup"`
+ ParentId int64 `json:"ixParent"`
+ IsCentral bool `json:"fCentral"`
+ Slug string `json:"sSlug"`
+ GroupSlug string `json:"sGroupSlug"`
+ ProjectSlug string `json:"sProjectSlug"`
+ GitUrl string `json:"sGitUrl"`
+ GitSshUrl string `json:"sGitSshUrl"`
+ Name string `json:"sName"`
+ Description string `json:"sDescription"`
+ Status string `json:"sStatus"`
+ Size int64 `json:"bytesSize"`
+ Vcs int `json:"vcs"`
+ Creator Person `json:"personCreator"`
+ DefaultPermission string `json:"permissionDefault"`
+ Branches []Repo `json:"repoBranches"`
}
-type KilnPerson struct {
+type Person struct {
Id int64 `json:"ixPerson"`
Name string `json:"sName"`
Email string `json:"sEmail"`
}
-func (k *KilnClient) CreateBranch(repoPath, branchName string) (newRepo *KilnRepo, err error) {
+func (k *Client) CreateBranch(repoPath, branchName string) (newRepo *Repo, err error) {
r, err := k.RepoForPath(repoPath)
if err != nil {
return
@@ -72,28 +72,28 @@ }
var resp []byte
if resp, err = k.apiPost("Repo/Create", params); err == nil {
- var errors map[string][]KilnError
+ var errors map[string][]ApiError
if err = json.Unmarshal(resp, &errors); err == nil {
if kilnErr, _ := errors["errors"]; len(kilnErr) > 0 {
err = fmt.Errorf("failed: %v\n", kilnErr[0].Description)
return
}
}
- newRepo = new(KilnRepo)
+ newRepo = new(Repo)
err = json.Unmarshal(resp, newRepo)
return
}
return
}
-func (k *KilnClient) Projects() (projects []KilnProject, err error) {
+func (k *Client) Projects() (projects []Project, err error) {
if resp, err := k.apiGet("Project", apiParams{}); err == nil {
err = json.Unmarshal(resp, &projects)
}
return
}
-func (k *KilnClient) RepoForPath(repoPath string) (*KilnRepo, error) {
+func (k *Client) RepoForPath(repoPath string) (*Repo, error) {
parts := strings.Split(repoPath, "/")
if len(parts) != 3 {
return nil, fmt.Errorf("unknown repository target: %v", repoPath)
@@ -114,7 +114,7 @@ return nil, fmt.Errorf("repository not found")
}
-func (k *KilnClient) IdForRepo(repoPath string) (int64, error) {
+func (k *Client) IdForRepo(repoPath string) (int64, error) {
repo, err := k.RepoForPath(repoPath)
if err != nil {
return -1, err
@@ -122,7 +122,7 @@ return repo.Id, nil
}
-func (k *KilnClient) RelatedRepos(repoPath string) (repos []KilnRepo, err error) {
+func (k *Client) RelatedRepos(repoPath string) (repos []Repo, err error) {
repoId, err := k.IdForRepo(repoPath)
if err == nil {
resp, err := k.apiGet(fmt.Sprintf("Repo/%v/Related", repoId), apiParams{})
|
@@ -112,7 +112,7 @@ }
}
-func requireAuth(k *kiln.KilnClient) {
+func requireAuth(k *kiln.Client) {
if err := k.EnsureCredentials(); err != nil {
fmt.Fprintf(os.Stderr, "unable to logon: %v\n", err)
os.Exit(1)
@@ -131,8 +131,8 @@ return
}
-func findTargets(related []kiln.KilnRepo, project, group, repo string) []kiln.KilnRepo {
- targets := make([]kiln.KilnRepo, 0)
+func findTargets(related []kiln.Repo, project, group, repo string) []kiln.Repo {
+ targets := make([]kiln.Repo, 0)
for _, r := range related {
if r.Slug == repo &&
(len(group) == 0 || r.GroupSlug == group) &&
@@ -143,7 +143,7 @@ return targets
}
-func dispatch(k *kiln.KilnClient, repoPath string) {
+func dispatch(k *kiln.Client, repoPath string) {
var command string
if len(os.Args) == 1 {
command = "history"
@@ -286,6 +286,6 @@ fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(1)
}
- k := kiln.NewKilnClient(kilnUrl)
+ k := kiln.NewClient(kilnUrl)
dispatch(k, repoPath)
}
|
Loading...