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

add create-branch command

Changeset 3dd53a8cb267

Parent ecc7c507cff2

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

Changes to 2 files · Browse files at 3dd53a8cb267 Showing diff from parent ecc7c507cff2 Diff from another changeset...

Change 1 of 2 Show Entire File kiln/​api.go Stacked
 
3
4
5
 
6
7
8
 
58
59
60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
62
63
 
3
4
5
6
7
8
9
 
59
60
61
62
63
64
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
@@ -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)
Change 1 of 1 Show Entire File main.go Stacked
 
206
207
208
 
 
 
 
 
 
 
 
 
 
209
210
211
 
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
@@ -206,6 +206,16 @@
  k.BrowseAnnotatedFile(repoPath, file)   }   } + case "create-branch": + if ensureArgs(3, "you must provide a branch name to create") { + requireAuth(k) + r, err := k.CreateBranch(repoPath, os.Args[2]) + if err != nil { + fmt.Fprintf(os.Stderr, "could not create branch: %v\n", err) + } else { + fmt.Printf("created: %v\n", r.GitUrl) + } + }   case "filehistory":   if ensureArgs(3, "you must provide at least one file to view") {   for _, file := range os.Args[2:len(os.Args)] {