Changeset 3dd53a8cb267…
Parent ecc7c507cff2…
by Benjamin Pollack <benjamin@fogcreek.com>
Changes to 2 files · Browse files at 3dd53a8cb267 Showing diff from parent ecc7c507cff2 Diff from another changeset...
@@ -3,6 +3,7 @@ import (
"encoding/json"
"fmt"
+ "strconv"
"strings"
)
@@ -58,6 +59,33 @@ Email string `json:"sEmail"`
}
+func (k *KilnClient) CreateBranch(repoPath, branchName string) (newRepo *KilnRepo, err error) {
+ r, err := k.RepoForPath(repoPath)
+ if err != nil {
+ return
+ }
+ params := apiParams{
+ "sName": branchName,
+ "ixRepoGroup": strconv.FormatInt(r.RepoGroupId, 10),
+ "ixParent": strconv.FormatInt(r.Id, 10),
+ "fCentral": "false",
+ }
+ var resp []byte
+ if resp, err = k.apiPost("Repo/Create", params); err == nil {
+ var errors map[string][]KilnError
+ 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)
+ err = json.Unmarshal(resp, newRepo)
+ return
+ }
+ return
+}
+
func (k *KilnClient) Projects() (projects []KilnProject, err error) {
if resp, err := k.apiGet("Project", apiParams{}); err == nil {
err = json.Unmarshal(resp, &projects)
|
Loading...