Unverified Commit 88f2514a authored by Shawna Monero's avatar Shawna Monero Committed by GitHub
Browse files

add parent to parent (#1631)

parent a9683f4f
Showing with 17 additions and 5 deletions
+17 -5
......@@ -365,6 +365,7 @@ type Commit struct {
Files []*githubv3.CommitFile
Message string
Author *githubv3.User
ParentRef string
}
func (s *svc) GetCommit(ctx context.Context, ref *RemoteRef) (*Commit, error) {
......@@ -374,11 +375,17 @@ func (s *svc) GetCommit(ctx context.Context, ref *RemoteRef) (*Commit, error) {
}
// Currently we are using the Author (Github) rather than commit Author (Git)
return &Commit{
retCommit := &Commit{
Files: commit.Files,
Message: commit.GetCommit().GetMessage(),
Author: commit.GetAuthor(),
}, nil
}
if commit.Parents != nil && len(commit.Parents) > 0 {
retCommit.ParentRef = commit.Parents[0].GetSHA()
}
return retCommit, nil
}
func (s *svc) GetRepository(ctx context.Context, repo *RemoteRef) (*Repository, error) {
......
......@@ -372,6 +372,7 @@ var getCommitsTests = []struct {
authorLogin string
authorAvatarURL string
authorID int64
parentRef string
}{
{
name: "v3 error",
......@@ -385,6 +386,7 @@ var getCommitsTests = []struct {
message: "committing some changes (#1)",
authorAvatarURL: "https://foo.bar/baz.png",
authorID: 1234,
parentRef: "test",
},
}
......@@ -422,6 +424,9 @@ func TestGetCommit(t *testing.T) {
a.Equal(tt.authorAvatarURL, *commit.Author.AvatarURL)
a.Equal(tt.authorID, *commit.Author.ID)
}
if commit.ParentRef != "" {
a.Equal(tt.parentRef, commit.ParentRef)
}
a.Nil(err)
})
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment