Skip to content
This repository has been archived by the owner on Dec 18, 2020. It is now read-only.

Commit

Permalink
fix branch creation for existing branch
Browse files Browse the repository at this point in the history
  • Loading branch information
sbruhns committed Jan 23, 2018
1 parent a5aeef2 commit 141115b
Showing 1 changed file with 31 additions and 27 deletions.
58 changes: 31 additions & 27 deletions push.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,33 +63,37 @@ func (cmd *PushCommand) Run() error {
projectsAffected[source.ProjectID] = true
}

for projectID := range projectsAffected {

branchPrams := &phraseapp.BranchParams{Name: &cmd.Branch}
branch, _ := client.BranchCreate(projectID, branchPrams)

fmt.Println()

taskResult := make(chan string, 1)
taskErr := make(chan error, 1)

fmt.Printf("Waiting for branch %s is created!", branch.Name)
spinner.While(func() {
branchCreateResult, err := getBranchCreateResult(client, projectID, branch)
taskResult <- branchCreateResult
taskErr <- err
})
fmt.Println()

if err := <-taskErr; err != nil {
return err
}

switch <-taskResult {
case "success":
print.Success("Successfully created branch %s", branch.Name)
case "error":
print.Failure("There was an error creating branch %s.", branch.Name)
if cmd.Branch != "" {
for projectID := range projectsAffected {
_, err := client.BranchShow(projectID, cmd.Branch)
if err != nil {
branchPrams := &phraseapp.BranchParams{Name: &cmd.Branch}
branch, _ := client.BranchCreate(projectID, branchPrams)

fmt.Println()

taskResult := make(chan string, 1)
taskErr := make(chan error, 1)

fmt.Printf("Waiting for branch %s is created!", branch.Name)
spinner.While(func() {
branchCreateResult, err := getBranchCreateResult(client, projectID, branch)
taskResult <- branchCreateResult
taskErr <- err
})
fmt.Println()

if err := <-taskErr; err != nil {
return err
}

switch <-taskResult {
case "success":
print.Success("Successfully created branch %s", branch.Name)
case "error":
print.Failure("There was an error creating branch %s.", branch.Name)
}
}
}
}

Expand Down

0 comments on commit 141115b

Please sign in to comment.