Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graphqa api changes #107

Merged
merged 3 commits into from
Sep 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions github_graphql.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,24 @@ func (g *GitHubClient) listReleasesV4() ([]*github.RepositoryRelease, error) {
publishedAt, _ := time.ParseInLocation(time.RFC3339, r.Node.PublishedAt.Time.Format(time.RFC3339), time.UTC)
createdAt, _ := time.ParseInLocation(time.RFC3339, r.Node.CreatedAt.Time.Format(time.RFC3339), time.UTC)
var releaseID int64
decodedID, err := base64.StdEncoding.DecodeString(r.Node.ID)
if err != nil {
return nil, err
}
re := regexp.MustCompile(`.*[^\d]`)
decodedID = re.ReplaceAll(decodedID, []byte(""))
if string(decodedID) == "" {
return nil, errors.New("bad release id from graph ql api")
}
releaseID, err = strconv.ParseInt(string(decodedID), 10, 64)
if err != nil {
return nil, err
if r.Node.DatabaseId == 0 {
decodedID, err := base64.StdEncoding.DecodeString(r.Node.ID)
if err != nil {
return nil, err
}
re := regexp.MustCompile(`.*[^\d]`)
decodedID = re.ReplaceAll(decodedID, []byte(""))
if string(decodedID) == "" {
return nil, errors.New("bad release id from graph ql api")
}
releaseID, err = strconv.ParseInt(string(decodedID), 10, 64)
if err != nil {
return nil, err
}
} else {
releaseID = int64(r.Node.DatabaseId)
}

allReleases = append(allReleases, &github.RepositoryRelease{
ID: &releaseID,
TagName: &r.Node.TagName,
Expand Down
4 changes: 4 additions & 0 deletions github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const (
"node": {
"createdAt": "2010-10-01T00:58:07Z",
"id": "MDc6UmVsZWFzZTMyMDk1MTAz",
"databaseId": 32095103,
"name": "xyz",
"publishedAt": "2010-10-02T15:39:53Z",
"tagName": "xyz",
Expand All @@ -37,6 +38,7 @@ const (
"node": {
"createdAt": "2010-08-27T13:55:36Z",
"id": "MDc6UmVsZWFzZTMwMjMwNjU5",
"databaseId": 30230659,
"name": "xyz",
"publishedAt": "2010-08-27T17:18:06Z",
"tagName": "xyz",
Expand Down Expand Up @@ -64,6 +66,7 @@ const (
"node": {
"createdAt": "2010-10-10T01:01:07Z",
"id": "MDc6UmVsZWFzZTMzMjIyMjQz",
"databaseId": 33222243,
"name": "xyq",
"publishedAt": "2010-10-10T15:39:53Z",
"tagName": "xyq",
Expand All @@ -90,6 +93,7 @@ const (
"node": {
"createdAt": "2010-10-10T01:01:07Z",
"id": "MDc6UmVsZWFzZTMzMjZyzzzz",
"databaseId":"3322224a",
"name": "xyq",
"publishedAt": "2010-10-10T15:39:53Z",
"tagName": "xyq",
Expand Down
1 change: 1 addition & 0 deletions model.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ type ReleaseObject struct {
CreatedAt githubv4.DateTime `graphql:"createdAt"`
PublishedAt githubv4.DateTime `graphql:"publishedAt"`
ID string `graphql:"id"`
DatabaseId githubv4.Int `graphql:"databaseId"`
IsDraft bool `graphql:"isDraft"`
IsPrerelease bool `graphql:"isPrerelease"`
Name string `graphql:"name"`
Expand Down