@@ -330,3 +330,90 @@ func (s *RepositoriesService) MergeBase(pid interface{}, opt *MergeBaseOptions,
330
330
331
331
return c , resp , err
332
332
}
333
+
334
+ // AddChangelogOptions represents the available AddChangelog() options.
335
+ //
336
+ // GitLab API docs:
337
+ // https://docs.gitlab.com/ee/api/repositories.html#add-changelog-data-to-a-changelog-file
338
+ type AddChangelogOptions struct {
339
+ Version * string `url:"version,omitempty" json:"version,omitempty"`
340
+ Branch * string `url:"branch,omitempty" json:"branch,omitempty"`
341
+ ConfigFile * string `url:"config_file,omitempty" json:"config_file,omitempty"`
342
+ Date * ISOTime `url:"date,omitempty" json:"date,omitempty"`
343
+ File * string `url:"file,omitempty" json:"file,omitempty"`
344
+ From * string `url:"from,omitempty" json:"from,omitempty"`
345
+ Message * string `url:"message,omitempty" json:"message,omitempty"`
346
+ To * string `url:"to,omitempty" json:"to,omitempty"`
347
+ Trailer * string `url:"trailer,omitempty" json:"trailer,omitempty"`
348
+ }
349
+
350
+ // AddChangelog generates changelog data based on commits in a repository.
351
+ //
352
+ // Gitlab API docs:
353
+ // https://docs.gitlab.com/ee/api/repositories.html#add-changelog-data-to-a-changelog-file
354
+ func (s * RepositoriesService ) AddChangelog (pid interface {}, opt * AddChangelogOptions , options ... RequestOptionFunc ) (* Response , error ) {
355
+ project , err := parseID (pid )
356
+ if err != nil {
357
+ return nil , err
358
+ }
359
+ u := fmt .Sprintf ("projects/%s/repository/changelog" , PathEscape (project ))
360
+
361
+ req , err := s .client .NewRequest (http .MethodPost , u , opt , options )
362
+ if err != nil {
363
+ return nil , err
364
+ }
365
+
366
+ return s .client .Do (req , nil )
367
+ }
368
+
369
+ // ChangelogData represents the generated changelog data.
370
+ //
371
+ // GitLab API docs:
372
+ // https://docs.gitlab.com/ee/api/repositories.html#generate-changelog-data
373
+ type ChangelogData struct {
374
+ Notes string `json:"notes"`
375
+ }
376
+
377
+ func (c ChangelogData ) String () string {
378
+ return Stringify (c )
379
+ }
380
+
381
+ // GenerateChangelogDataOptions represents the available GenerateChangelogData()
382
+ // options.
383
+ //
384
+ // GitLab API docs:
385
+ // https://docs.gitlab.com/ee/api/repositories.html#generate-changelog-data
386
+ type GenerateChangelogDataOptions struct {
387
+ Version * string `url:"version,omitempty" json:"version,omitempty"`
388
+ ConfigFile * string `url:"config_file,omitempty" json:"config_file,omitempty"`
389
+ Date * ISOTime `url:"date,omitempty" json:"date,omitempty"`
390
+ From * string `url:"from,omitempty" json:"from,omitempty"`
391
+ To * string `url:"to,omitempty" json:"to,omitempty"`
392
+ Trailer * string `url:"trailer,omitempty" json:"trailer,omitempty"`
393
+ }
394
+
395
+ // GenerateChangelogData generates changelog data based on commits in a
396
+ // repository, without committing them to a changelog file.
397
+ //
398
+ // Gitlab API docs:
399
+ // https://docs.gitlab.com/ee/api/repositories.html#generate-changelog-data
400
+ func (s * RepositoriesService ) GenerateChangelogData (pid interface {}, opt GenerateChangelogDataOptions , options ... RequestOptionFunc ) (* ChangelogData , * Response , error ) {
401
+ project , err := parseID (pid )
402
+ if err != nil {
403
+ return nil , nil , err
404
+ }
405
+ u := fmt .Sprintf ("projects/%s/repository/changelog" , project )
406
+
407
+ req , err := s .client .NewRequest (http .MethodGet , u , opt , options )
408
+ if err != nil {
409
+ return nil , nil , err
410
+ }
411
+
412
+ cd := new (ChangelogData )
413
+ resp , err := s .client .Do (req , cd )
414
+ if err != nil {
415
+ return nil , resp , err
416
+ }
417
+
418
+ return cd , resp , err
419
+ }
0 commit comments