Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
moul committed Oct 22, 2018
1 parent c2d490a commit 39848e7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
19 changes: 13 additions & 6 deletions github.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"context"
"encoding/json"
"fmt"
"log"
"strings"
Expand Down Expand Up @@ -70,14 +71,15 @@ func fromGithubUser(input *github.User) *Account {
}

func fromGithubRepository(input *github.Repository) *Repository {
fmt.Println(input)
panic("toto")
parts := strings.Split(*input.HTMLURL, "/")
panic("not implemented")
}

func fromGithubRepositoryURL(input string) *Repository {
return &Repository{
Base: Base{
ID: strings.Join(parts[0:len(parts)-2], "/"),
ID: input,
},
URL: strings.Join(parts[0:len(parts)-2], "/"),
URL: input,
Provider: &Provider{
Base: Base{
ID: "github", // FIXME: support multiple github instances
Expand Down Expand Up @@ -112,20 +114,25 @@ func fromGithubLabel(input *github.Label) *Label {
}

func fromGithubIssue(input *github.Issue) *Issue {
parts := strings.Split(*input.HTMLURL, "/")

body := ""
if input.Body != nil {
body = *input.Body
}
url := strings.Replace(*input.HTMLURL, "/pull/", "/issues/", -1)

out, _ := json.Marshal(input)
fmt.Println("input", string(out))

issue := &Issue{
Base: Base{
ID: url,
CreatedAt: *input.CreatedAt,
UpdatedAt: *input.UpdatedAt,
},
CompletedAt: input.GetClosedAt(),
Repository: fromGithubRepository(input.Repository),
Repository: fromGithubRepositoryURL(strings.Join(parts[0:len(parts)-2], "/")),
Title: *input.Title,
State: *input.State,
Body: body,
Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ func newRootCommand() *cobra.Command {
Account{},
Milestone{},
Repository{},
Provider{},
).Error; err != nil {
return err
}
Expand Down

0 comments on commit 39848e7

Please sign in to comment.