diff --git a/scm/driver/harness/git.go b/scm/driver/harness/git.go index f261f7756..59fadc3dd 100644 --- a/scm/driver/harness/git.go +++ b/scm/driver/harness/git.go @@ -133,23 +133,7 @@ type ( } commitInfo struct { - Author struct { - Identity struct { - Email string `json:"email"` - Name string `json:"name"` - } `json:"identity"` - When time.Time `json:"when"` - } `json:"author"` - Committer struct { - Identity struct { - Email string `json:"email"` - Name string `json:"name"` - } `json:"identity"` - When time.Time `json:"when"` - } `json:"committer"` - Message string `json:"message"` - Sha string `json:"sha"` - Title string `json:"title"` + commitInternal } branchInput struct { Name string `json:"name"` @@ -157,27 +141,9 @@ type ( BypassRules bool `json:"bypass_rules"` } branch struct { - Commit struct { - Author struct { - Identity struct { - Email string `json:"email"` - Name string `json:"name"` - } `json:"identity"` - When time.Time `json:"when"` - } `json:"author"` - Committer struct { - Identity struct { - Email string `json:"email"` - Name string `json:"name"` - } `json:"identity"` - When time.Time `json:"when"` - } `json:"committer"` - Message string `json:"message"` - Sha string `json:"sha"` - Title string `json:"title"` - } `json:"commit"` - Name string `json:"name"` - Sha string `json:"sha"` + Commit commitInternal `json:"commit"` + Name string `json:"name"` + Sha string `json:"sha"` } fileDiff struct { SHA string `json:"sha"` @@ -193,6 +159,25 @@ type ( IsBinary bool `json:"is_binary"` IsSubmodule bool `json:"is_submodule"` } + commitInternal struct { + Author struct { + Identity struct { + Email string `json:"email"` + Name string `json:"name"` + } `json:"identity"` + When time.Time `json:"when"` + } `json:"author"` + Committer struct { + Identity struct { + Email string `json:"email"` + Name string `json:"name"` + } `json:"identity"` + When time.Time `json:"when"` + } `json:"committer"` + Message string `json:"message"` + Sha string `json:"sha"` + Title string `json:"title"` + } ) // @@ -234,7 +219,7 @@ func convertChangeList(src []*fileDiff) []*scm.Change { func convertCommitInfo(src *commitInfo) *scm.Commit { return &scm.Commit{ Sha: src.Sha, - Message: src.Message, + Message: src.Title, Author: scm.Signature{ Name: src.Author.Identity.Name, Email: src.Author.Identity.Email, diff --git a/scm/driver/harness/pr.go b/scm/driver/harness/pr.go index 167ba9bf7..f199991cb 100644 --- a/scm/driver/harness/pr.go +++ b/scm/driver/harness/pr.go @@ -7,11 +7,12 @@ package harness import ( "context" "fmt" - "github.com/drone/go-scm/scm/driver/internal/null" "strconv" "strings" "time" + "github.com/drone/go-scm/scm/driver/internal/null" + "github.com/drone/go-scm/scm" ) @@ -59,9 +60,9 @@ func (s *pullService) ListCommits(ctx context.Context, repo string, index int, o return nil, nil, err } path := fmt.Sprintf("api/v1/repos/%s/pullreq/%d/commits?%s&%s", repoId, index, encodeListOptions(opts), queryParams) - out := []*commit{} + out := []commitInfo{} res, err := s.client.do(ctx, "GET", path, nil, &out) - return convertCommits(out), res, err + return convertCommitList(&commits{out}), res, err } func (s *pullService) ListChanges(ctx context.Context, repo string, number int, _ scm.ListOptions) ([]*scm.Change, *scm.Response, error) { @@ -173,25 +174,6 @@ type ( Title string `json:"title"` } - commit struct { - Author struct { - Identity struct { - Email string `json:"email"` - Name string `json:"name"` - } `json:"identity"` - When time.Time `json:"when"` - } `json:"author"` - Committer struct { - Identity struct { - Email string `json:"email"` - Name string `json:"name"` - } `json:"identity"` - When time.Time `json:"when"` - } `json:"committer"` - Message string `json:"message"` - Sha string `json:"sha"` - Title string `json:"title"` - } prComment struct { LineEnd int `json:"line_end"` LineEndNew bool `json:"line_end_new"` @@ -272,7 +254,7 @@ func convertPullRequest(src *pr) *scm.PullRequest { } } -func convertCommits(src []*commit) []*scm.Commit { +func convertCommits(src []*commitInfo) []*scm.Commit { dst := []*scm.Commit{} for _, v := range src { dst = append(dst, convertCommit(v)) @@ -280,7 +262,7 @@ func convertCommits(src []*commit) []*scm.Commit { return dst } -func convertCommit(src *commit) *scm.Commit { +func convertCommit(src *commitInfo) *scm.Commit { return &scm.Commit{ Message: src.Message, Sha: src.Sha,