Skip to content

Commit 3b21a0f

Browse files
fix: Harness list commits api update as per new spec (#277)
1 parent 60fa179 commit 3b21a0f

File tree

2 files changed

+30
-24
lines changed

2 files changed

+30
-24
lines changed

scm/driver/harness/git.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func (s *gitService) ListBranchesV2(ctx context.Context, repo string, opts scm.B
6363
func (s *gitService) ListCommits(ctx context.Context, repo string, _ scm.CommitListOptions) ([]*scm.Commit, *scm.Response, error) {
6464
harnessURI := buildHarnessURI(s.client.account, s.client.organization, s.client.project, repo)
6565
path := fmt.Sprintf("api/v1/repos/%s/commits", harnessURI)
66-
out := []*commitInfo{}
66+
out := new(commits)
6767
res, err := s.client.do(ctx, "GET", path, nil, &out)
6868
return convertCommitList(out), res, err
6969
}
@@ -86,6 +86,10 @@ func (s *gitService) CompareChanges(ctx context.Context, repo, source, target st
8686

8787
// native data structures
8888
type (
89+
commits struct {
90+
Commits []commitInfo `json:"commits"`
91+
}
92+
8993
commitInfo struct {
9094
Author struct {
9195
Identity struct {
@@ -168,10 +172,10 @@ func convertBranch(src *branch) *scm.Reference {
168172
}
169173
}
170174

171-
func convertCommitList(src []*commitInfo) []*scm.Commit {
172-
dst := []*scm.Commit{}
173-
for _, v := range src {
174-
dst = append(dst, convertCommitInfo(v))
175+
func convertCommitList(src *commits) []*scm.Commit {
176+
var dst []*scm.Commit
177+
for _, v := range src.Commits {
178+
dst = append(dst, convertCommitInfo(&v))
175179
}
176180
return dst
177181
}
Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
1-
[
2-
{
3-
"sha": "1d640265d8bdd818175fa736f0fcbad2c9b716c9",
4-
"title": "delete README.2",
5-
"message": "delete README.2\n\ndelete README.2",
6-
"author": {
7-
"identity": {
8-
"name": "thomas.honey",
9-
"email": "[email protected]"
1+
{
2+
"commits": [
3+
{
4+
"sha": "1d640265d8bdd818175fa736f0fcbad2c9b716c9",
5+
"title": "delete README.2",
6+
"message": "delete README.2\n\ndelete README.2",
7+
"author": {
8+
"identity": {
9+
"name": "thomas.honey",
10+
"email": "[email protected]"
11+
},
12+
"when": "2023-02-08T16:17:50Z"
1013
},
11-
"when": "2023-02-08T16:17:50Z"
12-
},
13-
"committer": {
14-
"identity": {
15-
"name": "Harness",
16-
"email": "[email protected]"
17-
},
18-
"when": "2023-02-08T16:17:50Z"
14+
"committer": {
15+
"identity": {
16+
"name": "Harness",
17+
"email": "[email protected]"
18+
},
19+
"when": "2023-02-08T16:17:50Z"
20+
}
1921
}
20-
}
21-
]
22+
]
23+
}

0 commit comments

Comments
 (0)