Skip to content

Commit d9147fb

Browse files
Merge pull request #328 from drone/PIPE-23808
feat: [PIPE-23808]: integrate author details with the harness commits API
2 parents d5ed63c + 31d79c4 commit d9147fb

File tree

2 files changed

+101
-99
lines changed

2 files changed

+101
-99
lines changed

scm/content.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ type (
4040
// Find returns the repository file content by path.
4141
Find(ctx context.Context, repo, path, ref string) (*Content, *Response, error)
4242

43-
// Create creates a new repositroy file.
43+
// Create creates a new repository file.
4444
Create(ctx context.Context, repo, path string, params *ContentParams) (*Response, error)
4545

4646
// Update updates a repository file.
4747
Update(ctx context.Context, repo, path string, params *ContentParams) (*Response, error)
4848

49-
// Delete deletes a reository file.
49+
// Delete deletes a repository file.
5050
Delete(ctx context.Context, repo, path string, params *ContentParams) (*Response, error)
5151

5252
// List returns a list of contents in a repository directory by path. It is

scm/driver/harness/content.go

+99-97
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ func (s *contentService) Create(ctx context.Context, repo, path string, params *
5555
Title: params.Message,
5656
Actions: []action{a},
5757
BypassRules: true,
58+
Author: identity{
59+
Name: params.Signature.Name,
60+
Email: params.Signature.Email,
61+
},
5862
}
5963

6064
res, err := s.client.do(ctx, "POST", endpoint, in, nil)
@@ -81,6 +85,10 @@ func (s *contentService) Update(ctx context.Context, repo, path string, params *
8185
Title: params.Message,
8286
Actions: []action{a},
8387
BypassRules: true,
88+
Author: identity{
89+
Name: params.Signature.Name,
90+
Email: params.Signature.Email,
91+
},
8492
}
8593

8694
res, err := s.client.do(ctx, "POST", endpoint, in, nil)
@@ -105,6 +113,10 @@ func (s *contentService) Delete(ctx context.Context, repo, path string, params *
105113
Title: params.Message,
106114
Actions: []action{a},
107115
BypassRules: true,
116+
Author: identity{
117+
Name: params.Signature.Name,
118+
Email: params.Signature.Email,
119+
},
108120
}
109121

110122
res, err := s.client.do(ctx, "POST", endpoint, in, nil)
@@ -123,109 +135,99 @@ func (s *contentService) List(ctx context.Context, repo, path, ref string, _ scm
123135
return convertContentInfoList(out.Content.Entries), res, err
124136
}
125137

126-
type editFile struct {
127-
Actions []action `json:"actions"`
128-
Branch string `json:"branch"`
129-
Message string `json:"message"`
130-
NewBranch string `json:"new_branch"`
131-
Title string `json:"title"`
138+
type (
139+
identity struct {
140+
Name string `json:"name"`
141+
Email string `json:"email"`
142+
}
132143

133-
BypassRules bool `json:"bypass_rules"`
134-
}
144+
editFile struct {
145+
Actions []action `json:"actions"`
146+
Author identity `json:"author"`
147+
Branch string `json:"branch"`
148+
Message string `json:"message"`
149+
NewBranch string `json:"new_branch"`
150+
Title string `json:"title"`
135151

136-
type action struct {
137-
Action string `json:"action"`
138-
Encoding string `json:"encoding"`
139-
Path string `json:"path"`
140-
Payload string `json:"payload"`
141-
Sha string `json:"sha"`
142-
}
152+
BypassRules bool `json:"bypass_rules"`
153+
}
143154

144-
type fileContent struct {
145-
Type string `json:"type"`
146-
Sha string `json:"sha"`
147-
Name string `json:"name"`
148-
Path string `json:"path"`
149-
LatestCommit struct {
150-
Sha string `json:"sha"`
151-
Title string `json:"title"`
152-
Message string `json:"message"`
153-
Author struct {
154-
Identity struct {
155-
Name string `json:"name"`
156-
Email string `json:"email"`
157-
} `json:"identity"`
158-
When time.Time `json:"when"`
159-
} `json:"author"`
160-
Committer struct {
161-
Identity struct {
162-
Name string `json:"name"`
163-
Email string `json:"email"`
164-
} `json:"identity"`
165-
When time.Time `json:"when"`
166-
} `json:"committer"`
167-
} `json:"latest_commit"`
168-
Content struct {
155+
action struct {
156+
Action string `json:"action"`
169157
Encoding string `json:"encoding"`
170-
Data string `json:"data"`
171-
Size int `json:"size"`
172-
} `json:"content"`
173-
}
158+
Path string `json:"path"`
159+
Payload string `json:"payload"`
160+
Sha string `json:"sha"`
161+
}
174162

175-
type contentList struct {
176-
Type string `json:"type"`
177-
Sha string `json:"sha"`
178-
Name string `json:"name"`
179-
Path string `json:"path"`
180-
LatestCommit struct {
181-
Sha string `json:"sha"`
182-
Title string `json:"title"`
183-
Message string `json:"message"`
184-
Author struct {
185-
Identity struct {
186-
Name string `json:"name"`
187-
Email string `json:"email"`
188-
} `json:"identity"`
189-
When time.Time `json:"when"`
190-
} `json:"author"`
191-
Committer struct {
192-
Identity struct {
193-
Name string `json:"name"`
194-
Email string `json:"email"`
195-
} `json:"identity"`
196-
When time.Time `json:"when"`
197-
} `json:"committer"`
198-
} `json:"latest_commit"`
199-
Content struct {
200-
Entries []fileEntry `json:"entries"`
201-
} `json:"content"`
202-
}
163+
fileContent struct {
164+
Type string `json:"type"`
165+
Sha string `json:"sha"`
166+
Name string `json:"name"`
167+
Path string `json:"path"`
168+
LatestCommit struct {
169+
Sha string `json:"sha"`
170+
Title string `json:"title"`
171+
Message string `json:"message"`
172+
Author struct {
173+
Identity identity `json:"identity"`
174+
When time.Time `json:"when"`
175+
} `json:"author"`
176+
Committer struct {
177+
Identity identity `json:"identity"`
178+
When time.Time `json:"when"`
179+
} `json:"committer"`
180+
} `json:"latest_commit"`
181+
Content struct {
182+
Encoding string `json:"encoding"`
183+
Data string `json:"data"`
184+
Size int `json:"size"`
185+
} `json:"content"`
186+
}
203187

204-
type fileEntry struct {
205-
Type string `json:"type"`
206-
Sha string `json:"sha"`
207-
Name string `json:"name"`
208-
Path string `json:"path"`
209-
LatestCommit struct {
210-
Sha string `json:"sha"`
211-
Title string `json:"title"`
212-
Message string `json:"message"`
213-
Author struct {
214-
Identity struct {
215-
Name string `json:"name"`
216-
Email string `json:"email"`
217-
} `json:"identity"`
218-
When time.Time `json:"when"`
219-
} `json:"author"`
220-
Committer struct {
221-
Identity struct {
222-
Name string `json:"name"`
223-
Email string `json:"email"`
224-
} `json:"identity"`
225-
When time.Time `json:"when"`
226-
} `json:"committer"`
227-
} `json:"latest_commit"`
228-
}
188+
contentList struct {
189+
Type string `json:"type"`
190+
Sha string `json:"sha"`
191+
Name string `json:"name"`
192+
Path string `json:"path"`
193+
LatestCommit struct {
194+
Sha string `json:"sha"`
195+
Title string `json:"title"`
196+
Message string `json:"message"`
197+
Author struct {
198+
Identity identity `json:"identity"`
199+
When time.Time `json:"when"`
200+
} `json:"author"`
201+
Committer struct {
202+
Identity identity `json:"identity"`
203+
When time.Time `json:"when"`
204+
} `json:"committer"`
205+
} `json:"latest_commit"`
206+
Content struct {
207+
Entries []fileEntry `json:"entries"`
208+
} `json:"content"`
209+
}
210+
211+
fileEntry struct {
212+
Type string `json:"type"`
213+
Sha string `json:"sha"`
214+
Name string `json:"name"`
215+
Path string `json:"path"`
216+
LatestCommit struct {
217+
Sha string `json:"sha"`
218+
Title string `json:"title"`
219+
Message string `json:"message"`
220+
Author struct {
221+
Identity identity `json:"identity"`
222+
When time.Time `json:"when"`
223+
} `json:"author"`
224+
Committer struct {
225+
Identity identity `json:"identity"`
226+
When time.Time `json:"when"`
227+
} `json:"committer"`
228+
} `json:"latest_commit"`
229+
}
230+
)
229231

230232
func convertContentInfoList(from []fileEntry) []*scm.ContentInfo {
231233
to := []*scm.ContentInfo{}

0 commit comments

Comments
 (0)